PC Nerd Posted April 8, 2007 Share Posted April 8, 2007 um, im setting 3 cookies but theyre all storing the current timestamp, and theres some other cookie that i used to use, but no longer do, its still there this is my code $User_Name = $_POST['User_Name']; $User_ID = $Login['User_ID']; $Login_ID = $Login['Login_ID']; #$Logged_In = "YES"; #$Active = "Yes"; setcookie("User_Name", $User_Name, strtotime('+ 30 minutes')); setcookie("Login_ID", $Login_ID, strtotime('+ 30 minutes')); setcookie("User_ID", $User_ID, strtotime('+ 30 minutes')); thats the contents of the create cookies inc this is the login file <?php $now = date("U"); #echo $now; $Login_SQL = "INSERT INTO Login_Records (User_ID, Logged_In) VALUES ('".$DB_Login['User_ID']."', '".$now."')"; $Login_Query = mysqli_query($DB_Server, $Login_SQL); # or die("Could not Login. Please try again later"); unset($Login_SQL, $Login_Query); $Login_SQL = "SELECT User_ID, Login_ID FROM Login_Records WHERE User_ID ='".$DB_Login['User_ID']."' AND Logged_In = '".$now."'"; $Login_Query = mysqli_query($DB_Server, $Login_SQL) or die("Could not login. Please try again later"); $Login = mysqli_fetch_array($Login_Query); ?> can anyone see whats happening this is the output when i echo the contents of the cookies ( through a foreach ) User_Name => 1176012801 Logged_In => 1176012801 Login_ID => 1176012801 User_ID => 1176012801 thankx Quote Link to comment Share on other sites More sharing options...
HaLo2FrEeEk Posted April 8, 2007 Share Posted April 8, 2007 All I can see is that you are still calling up logged_in in your query. Where does $db_login[] come from. Quote Link to comment Share on other sites More sharing options...
dsaba Posted April 8, 2007 Share Posted April 8, 2007 always remember: you cannot set cookies and echo them in the same page load you must refresh to use the data in the cookies this means that you must not set the cookies everytime the page loads, you must make an if/else statement to ONLY set the cookie if it isn't already set if(!isset($_COOKIE['whatever'])) { //set the cookie } else { echo $_COOKIE['whatever']; } Quote Link to comment Share on other sites More sharing options...
HaLo2FrEeEk Posted April 8, 2007 Share Posted April 8, 2007 Ooooh, good point, how did I miss that. Good eye. Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 8, 2007 Author Share Posted April 8, 2007 ok, the output is in B_A-Base.php, yet another page. all of these files are included in the Login4.php file ill post the code below ( thats where $DB_Login comes in) <?php $username = $_POST['User_Name']; $password = $_POST['Password']; $valid = $_POST['Valid']; #echo "Username: {$username}<br>Password: {$password}<br>Valid: {$valid}<br><br>"; //echo out the values to see if they are being sent. $Error = ""; $Error1 = ""; $Error2 = ""; $Error3 = ""; $Error4 = ""; if($username != "" && $password != "" && $valid != "") { require('inc_files/Login_Pics.inc'); $img = "B_A-Login_".$_POST['IMG_Valid']; $Image_Validate = $IMAGES["$img"]; if($_POST['Valid'] == $Image_Validate) { require("inc_files/Database_link.inc"); $SQL_Login = "SELECT User_Name, `Password`, User_ID FROM General_Stats WHERE User_Name = '".$_POST['User_Name']."'"; $Login_Query = mysqli_query($DB_Server, $SQL_Login); if(!empty($Login_Query)) { $DB_Login = mysqli_fetch_array($Login_Query); if($DB_Login['User_Name'] == $_POST['User_Name'] && $DB_Login['Password'] == $_POST['Password']) { require("inc_files/B_A-Login.inc"); header("Location: B_A-Base.php"); } else { $Error = True; $Error4 = True; } } else { $Error = True; $Error3 = True; } } else { $Error = True; $Error2 = True; } } else { $Error = True; $Error1 = True; } ?> HTML FORMATING HERE <?php #echo "<form name = 'Login_Relocation' action = 'B_A-Base.php' method = 'POST'>\n"; #echo "<input type = 'button' name = 'relocation' value = 'Play Battle-Ages'>\n"; #echo "</form>"; #echo "<a href = 'B_A-Base.php' alt = 'Base'>Player Battle-Ages</a>\n"; if($Error1 == True) { die("ERROR 1 You have not filled in the log in fields. Click <a href = 'B_A-Home.php' alt = 'Home'>here</a> to return to the Home Page."); } if($Error2 == True) { die("ERROR 2 You did not type in the correct validation image. Click <a href = 'B_A-Home.php' alt = 'Home'>here</a> to return to the Home Page."); } if($Error3 == True) { die("ERROR 3 There was an error in the Database. You have not been logged in. Click <a href = 'B_A-Home.php' alt = 'Home'>here</a> to return to the Home Page.");#.mysqli_error($Login_Query)); } if($Error4 == True) { die("ERROR 4 There was an error in the Database. You have not been logged in. Click <a href = 'B_A-Home.php' alt = 'Home'>here</a> to return to the Home Page.");#.mysqli_error($DB_Login)); } ?> thats the login file, or Master file that all the other stuff is included in thankx for your help.......... PS i am getting the output from the cookies in the next page, where the login is redirected after its logged in, seting cookies etc. thankyou Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 8, 2007 Author Share Posted April 8, 2007 anyone???? Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 8, 2007 Author Share Posted April 8, 2007 please??? Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 8, 2007 Author Share Posted April 8, 2007 ***bump*** Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 8, 2007 Author Share Posted April 8, 2007 ok, ive re read, and reread all the posts, and i cant seem to fix it im not resetting the cookies each page, nor do i want them to refresh or update at all. theyrs simply a login thing ,to ttell whether of not some one is logged in. thats why theyre expire time is 30 minutes, so that someone cant be logged in all the time also. they store the basic information about the user such as username, id, and the login id. that way i can send the queries that get the data. becauase the information is update almost every page refresh, and it is open to other user's so it needs to be updated to a database, and not just to the cookie is there anything else i should do, or any suggestions i should follow, because i cant create and test much more of the site until this starts working, becauase all the pages check for the cooie and "die()" if there isnt one thankx for all your help so far, PC Nerd Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 8, 2007 Author Share Posted April 8, 2007 plz Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 8, 2007 Author Share Posted April 8, 2007 ***bump*** Quote Link to comment Share on other sites More sharing options...
per1os Posted April 8, 2007 Share Posted April 8, 2007 7 posts in a row? sighs. Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 8, 2007 Author Share Posted April 8, 2007 its not like i havent been posting back elsewhere in the forums.............. Quote Link to comment Share on other sites More sharing options...
per1os Posted April 8, 2007 Share Posted April 8, 2007 Doesn't matter to me really. I do know the answer and was getting ready to post it until I saw that "WARNING: A user has posted message" and noticed it was you..again. Hopefully someone else can help you bud. Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 8, 2007 Author Share Posted April 8, 2007 well if you want a reply, and its coincedently at the same time, then its not my fautl is it????? i just say post it anyway, and hope it helps Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 8, 2007 Author Share Posted April 8, 2007 bump Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 8, 2007 Author Share Posted April 8, 2007 look, is there anything that i should be looking for, even just a "stab in the dark" ??? thanks if there is, and thankx if you can helkp solve it Quote Link to comment Share on other sites More sharing options...
Base Posted April 8, 2007 Share Posted April 8, 2007 Ok. so i am going to take a stab in the dark here. A complete stab in the dark, as i allways use sessions rather than cookies. But if i do every use cookies, i use: setcookie("COOKIENAME", "COOKIEVALUE", time() + 3600); (3600 = 1 hour) Rather than using: setcookie("User_Name", $User_Name, strtotime('+ 30 minutes'));[/code I dunno, it might help you.. if not then sorry! Base Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 8, 2007 Author Share Posted April 8, 2007 the values being saved to the cookies that arent working, not the expire time......... thankx anyway Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 9, 2007 Author Share Posted April 9, 2007 bmp Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 9, 2007 Author Share Posted April 9, 2007 plz**** i really need helpon this one Quote Link to comment Share on other sites More sharing options...
HaLo2FrEeEk Posted April 9, 2007 Share Posted April 9, 2007 Did you try clearing your cache of all cookies, making sure all of them are gone, then running the script again? Maybe it is picking up residual cookie...crumbs (lol, pun) Also, if no one is helping, just let it go, or make a new topic, don't keep bumping (7 times in a row) a topic, its rather obnoxious. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.