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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.