PC Nerd Posted April 9, 2007 Share Posted April 9, 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: $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 Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 9, 2007 Share Posted April 9, 2007 just a shot in the dark ... maybe $User_Name, $Login_ID & $User_ID are empty and that it's storing the strtotime('+30 minutes') instead? only reason i can think of since it's storing a timestamp Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 9, 2007 Author Share Posted April 9, 2007 um, i dont think thats it, becauase ive got that function that echos every value in the page, and all the arrays etc are full and the correct data thanks anyway can someone check if ive got my arguments for the cookies in the correct order? Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 9, 2007 Share Posted April 9, 2007 i check... and welll, they look ok... but why dont u just go to http://us2.php.net/manual/en/function.setcookie.php ?? hehe Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 9, 2007 Author Share Posted April 9, 2007 ok, im 99% sure that the syntax is right, but i cant see the error. thankx Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 9, 2007 Share Posted April 9, 2007 no problem... yeah I had some serious issues with cookies myself .. was doing something simular to you with the username and stuff... ended up using $_SESSION... now it works as a charm =) Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 9, 2007 Author Share Posted April 9, 2007 um clown[NOR], what did you do to try to try and fix the cookie problem before you tried sessions? i dont think my host allows session, and i dont want to rely on sessions of i can help it......... just so i can give it a go Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 9, 2007 Share Posted April 9, 2007 what I did wasnt 100% what you're trying, i was trying to use it for a shoutbox so the users didn't have to enter their nick and website everytime... when i come to think about it i gave the whole thing up, so they just have to write it now..hehe... but what i tried was 1) Setting the setcookie() inside an if statement (heard from someone on the forum that it might help) 2) i tried using variables, $_REQUEST, $_POST and something else, but i dont remember all of it.. btw... u dont have to use [NOR] =) that's just where i'm from Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 9, 2007 Author Share Posted April 9, 2007 lol, kk um, so do you have any more ideas??? untill this starts working, i cant edit much more of my site........... until the login works, ive built no back doors in for admin or mods. thankx PC Nerd Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 9, 2007 Share Posted April 9, 2007 hmm... only thing I can come up with now... after beeing up all night is FFD...hehe.. but that's not an option i guess =) how many users are you planning to be able to handle? unlimited? cuz ... if you dont have to many you could maybe make a folder called users or something, and have a file with the users username as filename .. haha... nah...forget it... that was a really retarded idea...haha *EDIT* About that backdoor... make a flatfile for admins and one for moderators... wow... i think that was a pretty good idea ;D btw... have you tried: $User_Name = $_POST['User_Name']; $User_ID = $Login['User_ID']; $Login_ID = $Login['Login_ID']; #$Logged_In = "YES"; #$Active = "Yes"; if (isset($User_name)) { setcookie("User_Name", $User_Name, strtotime('+ 30 minutes')); setcookie("Login_ID", $Login_ID, strtotime('+ 30 minutes')); setcookie("User_ID", $User_ID, strtotime('+ 30 minutes')); } or something simular? Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 9, 2007 Author Share Posted April 9, 2007 um, FFD ????? Flat file Database? its definately got to be a proper database, im looking at hundreds of people, A DAY!!!!! and new ones signing up. its a game called battle-ages ( http://www.battleages.tk) and its almost ready to release ( excuse the site, its slightly out of date and very primitive) but the games a lot better. the backdoor i was tlking about is more of an option for Mods and Admin, that doesnt require them to login....... to an extent ( ie relogin every 30 min lke everyone else........) but thatll come later i think how much better would sessions be?????. i would prefer cookies Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 9, 2007 Share Posted April 9, 2007 i like session very much =) i'm not skilled enough to say how much better it is =) hehe... leaving that question open for someone with more experience Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 9, 2007 Author Share Posted April 9, 2007 thanks anyway, could one of the more experienced guys explain???? thanks for all your help Clown, i appreciate it Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 9, 2007 Share Posted April 9, 2007 yeah no problem.. that's what this site is for aint it? Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 9, 2007 Author Share Posted April 9, 2007 exaclty!!!!! Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 9, 2007 Share Posted April 9, 2007 sorry i couldnt help you get it SOLVED... but good luck m8 Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 9, 2007 Author Share Posted April 9, 2007 hey np, and spread word about battleages ( if you feel like it, its designed by me and mates in AUS!!!!!, taken us about a year) and it wouldt have been done without PHPFREAKS!!!!!, so thanks to everyione!!!!! Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 9, 2007 Author Share Posted April 9, 2007 um i just relised that even after a few hours, and feleting all cookies from IE, that the cookies are stil there..... but im not actually creating any cookies..... whats happening do you think Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 9, 2007 Share Posted April 9, 2007 dunno... but i if i was you I would delete all cookies and try again... just to see.. sometimes cookies mess up things really bad... the gaming clan i'm in, when we moved from windows to linux servers, even when everything on the site was removed, the cookies made it so I still got the old site up.. but when i deleted all cookies everything was back the way it should have been in the first place =) so it's worth a try... Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 9, 2007 Author Share Posted April 9, 2007 ok..... i deleted all cookies, and it didnt work..... then i restarted computer, and there were no cookies i logged in again and the cookoies were back, still sith the timestamp........ now are cookies in IE7 saved in the Temporary internet files folder, or somewhere else? thankx Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 9, 2007 Share Posted April 9, 2007 dunno... but you could maybe try searching for it? hehe... search for User_Name or something... Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 9, 2007 Author Share Posted April 9, 2007 um also, is there a function that actually says the location of the cookie on the clients computer so that i can look manually for it????? Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 9, 2007 Share Posted April 9, 2007 google is my best friend =) searched for "ie7 cookie location" .. first hit was http://www.askaboutmoney.com/showthread.php?p=317271 worth a reading Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 9, 2007 Author Share Posted April 9, 2007 lol, thankx Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 9, 2007 Share Posted April 9, 2007 hehe... did it help? 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.