Jump to content

Overwrite cookie deletes it?


silkfire

Recommended Posts

I have some serious problem with my cookie setting script.

 

In my index file, a cookie is set by default if it's not already set. Lifetime: 1 month.

 

In my interface, I have a way to change settings, when the user presses okay, an AJAX call is issued which saves a cookie with the chosen settings.

If tried changing the expiry here to 1 month, 2 months, doesn't matter. The resulting script deletes my cookie for some reason. Why is this?

I've read to change cookie value you should use setcookie again (which I want, bc I want to extend the lifetime everytime user changes a setting), and not use the $_COOKIE variable to assign value.

 

I get response "deleted" which in practice deletes my cookie, plus it changes to Session when it's at least 1 month lifetime. What am I doing wrong?

 

if (isset($_POST['theme'])) {
   setcookie('theme', $_POST['theme'], strtotime('+2 month'));

   die();
}

 

 

1znuz2a.jpg

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.