Jump to content
  • Advertisement
Sign in to follow this  
Concentrate

I'm going crazies from cookies

This topic is 2703 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Please help me before I kill someone.

I am setting a cookie value to 0 from 1, in one page. then I redirect that page to index.html. Afterwards I check the cookie value its still 1, meaning the user is still logged in? Why oh Why didn't the cookie change ?
Some code :

This is the function to logout,


function logout(){
$_COOKIE[ACTIVE_SESSION] = 0;
}


when the user clicks on a link to logout, that link is a php file that calls this function. as of right now cookie[active_session] is 0. Its either 1 or 0. 1 = logged in, 0 = logged out.

Now php file redirects the location to index.html using meta refresh.

From index.html, I click a link that shows info about the user if he is logged in, here is the php code :


<?php
include("utility.php");

if(isLoggedIn()){
echo "<h1> Welcome '" . getUserName() . "' enjoy the scenery</h1>";
}
else{ //invalid user
echo "<h1>Sorry you are not registered...please wait for redirection</h1>";
redirectToHomePage(3);
}
?>


as you see isLoggedIn gets called first, remind you that cookie[active_session] should still be 0.

Now isLoggedIn() is this :


function isLoggedIn(){
if(isset($_COOKIE[ACTIVE_SESSION])){
return ( $_COOKIE[ACTIVE_SESSION] == 1) ;
}
else return false;
}


now the problem is that this function returned 1? WTF??

Please help me.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!