pneudralics Posted May 11, 2009 Share Posted May 11, 2009 //$idf gets primary id from database //$idsessionf gets idsession from database which is randomly generated when registration setcookie ('id', $idf['id']); setcookie ('idsession', $idsessionf['idsession']); //redirects to user page user page if(!isset($_COOKIE['id']) && !isset($_COOKIE['idsession'])){ //error } { //else yay! } When the broser prompts me to allow the cookie it always shows 1 character in the data section, even if 'id' as more than 1 character and 'idsession' is sha1 Quote Link to comment Share on other sites More sharing options...
jackpf Posted May 11, 2009 Share Posted May 11, 2009 I don't think you're giving setcookie() all the parameters it requires, such as expiry date, path and domain. Could be a reason. Quote Link to comment Share on other sites More sharing options...
revraz Posted May 11, 2009 Share Posted May 11, 2009 Those are all optional and if omitted: Would destroy the cookie when the browser is closed. Only work on the current path of the page. Only work on the current domain. Quote Link to comment Share on other sites More sharing options...
jackpf Posted May 11, 2009 Share Posted May 11, 2009 Yeah, true, it doesn't require them, but...it's probably why it isn't working Quote Link to comment Share on other sites More sharing options...
revraz Posted May 11, 2009 Share Posted May 11, 2009 Replace your variables with a string value and see how it works. If that works, echo your variables and verify they are what you think they are. Quote Link to comment Share on other sites More sharing options...
pneudralics Posted May 11, 2009 Author Share Posted May 11, 2009 //does not work setcookie ('id', $idf['id']); setcookie ('idsession', $idsessionf['idsession']); //works... setcookie ('id', $idf); setcookie ('idsession', $idsessionf); Now the issue is how do I check for $idf and $idsessionf? //This doesn't work anymore if(!isset($_COOKIE['id']) && !isset($_COOKIE['idsession'])){ //error } { //else yay! } Quote Link to comment Share on other sites More sharing options...
jackpf Posted May 11, 2009 Share Posted May 11, 2009 if(!isset($_COOKIE['id']) && !isset($_COOKIE['idsession'])){ //error } else { //else yay! } Should work. Quote Link to comment Share on other sites More sharing options...
pneudralics Posted May 11, 2009 Author Share Posted May 11, 2009 I got it! It did work. One of my require page was still including $_SESSION instead of $_COOKIE so it was throwing the error page. Thanks for all the 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.