Jump to content

Sessions and Cookies


crr_gm

Recommended Posts

I am having a hard time getting sessions and cookies to work as I would expect.  I am using codelobster editor/debugger and wampserver. 

My problem is that when I try to delete a cookie it shows that the cookie is still there and active.

 

<?PHP

session_start();

date_default_timezone_set('Asia/Qatar');

// I try to delete the previous cookie which was set

setcookie('my_session',"",time()-3600);

// here I have a function that sets a cookie

log_session("username","password");

session_destroy();

?>

 

When I check the local variables in the debugger they are still there and not deleted and have the same value.

Is my logic wrong or is it my system?

 

Link to comment
Share on other sites

Did you read the 'common pitfalls' on the setcookie-page?

 

Things I can think of:

* If you set or delete a cookie, it is visible when the page is reloaded - do you reload your page before checking?

* You use single and double quotes together

* Try explicitly setting the value of the cookie to 'false' - no need to set the time in the past, that is something that is done internally by PHP

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.