PC Nerd Posted April 12, 2007 Share Posted April 12, 2007 hi guys. im setting cookies for my login and instead of storing the values i want it to, its storing a timestamp instead my code is in a few pages, althoug ill summerise my data, and only post the code that creates the cookies: 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')); $Login is an array storing values retreive from the database. when loging in. it saves your login, time, user id to a table. $Login_Array is simply retreiving this record again, so that the Auto_increment field "login_ID" can be stored in the cookie. $DB_Login is a returned test to check whether or not the user_Name entered is even in the database..... $_POST['User_Name'] is the User_Name entered by the user to login. now my cookies are saving the following data, and theres still a "phanton" cookie that i used to use to have the expire time to check wherer or not their logged in.... The cookies are: User_Name => 1176012801 Logged_In => 1176012801 Login_ID => 1176012801 User_ID => 1176012801 these change everytime that the user logs in....... and gets deleted when the user logs out..... also, when i veiw the cookies on the page where they are created...... they are there, but i know that you shouldnt be able to veiw a cookoie on the page where its created.... i would really appreciate anyoes help in this problem, its been really annoying me for a few days now. thanks, PC Nerd PS, im reposting, becauase my other one becamase dead as it was very long. its here http://www.phpfreaks.com/forums/index.php/topic,135203.0.html Quote Link to comment Share on other sites More sharing options...
redking Posted April 12, 2007 Share Posted April 12, 2007 could you try running this and tell me if it runs correctly? (just give a known value to the variables) <?php $_POST['User_Name'] = "foo"; $Login['User_ID'] = 123; $Login['Login_ID'] = 123; $User_Name = $_POST['User_Name']; $User_ID = $Login['User_ID']; $Login_ID = $Login['Login_ID']; setcookie("User_Name", $User_Name, strtotime('+ 30 minutes')); setcookie("Login_ID", $Login_ID, strtotime('+ 30 minutes')); setcookie("User_ID", $User_ID, strtotime('+ 30 minutes')); ?> Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 12, 2007 Author Share Posted April 12, 2007 no sorry, its not working im still getting the timestamp output thanks Quote Link to comment Share on other sites More sharing options...
Glyde Posted April 12, 2007 Share Posted April 12, 2007 Just saved to a server on my localhost, ran it, worked fine. Checked Firefox cookies to ensure the values, came up with: User_Name: foo User_ID: 123 Login_ID: 123 It appears to be an issue with your browser. Either that or you have some content being printed to the user somehow before the setcookie command is sent. Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 13, 2007 Author Share Posted April 13, 2007 yeah i do, thankx um, shouldnt it be returning a "output sent by ..........." im logging the page request..... which is querying the database.......... if i user setcookie, then header, in another page, would that still work, becauase its all header information? i still dont know, becauase whenever i login again, the timestamp changes to the current ( i think its the current one) so ill try to change it, but i dont htink that itll work becauase of the timestamp..... thanks though, ill give it a go Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 13, 2007 Author Share Posted April 13, 2007 ok, now its relocating but the timestamp is always the same.......... would it be better for me to post all the files as attachemnts, or post them here...... theres about 3 or 4 files that are required to login. thanks for all you help Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 13, 2007 Author Share Posted April 13, 2007 um, any suggestions? 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.