Jump to content

Php cookies. (YES I'VE READ THE TUTORIALS.)


Moptop650

Recommended Posts

My cookies set by php are always deleting themselves when I close the browser. (NOT a browser preferance issue, I've checked.

 

Im using:

 

setcookie("mc-pref", $prefs, time()+525600);

 

And have tried:

 

setcookie("mc-pref", $prefs, time+525600);

 

setcookie("mc-pref", $prefs, $time+525600);

 

 

What am I doing wrong?

Link to comment
Share on other sites

If the cookies are deleted when the browser is closed, and no other time, I find it very hard to believe it's anything but a setting in the browser.

 

Perhaps, if you are on an AD domain, it's a profile setting that is clearing the cookies folder at logout.

Link to comment
Share on other sites

Maybe try using more of the setcookie parameters, such as domain and path???

 

www.php.net/setcookie

 

<?php
//bool setcookie ( string $name [, string $value [, int $expire [, string $path [, string $domain [, bool $secure [, bool $httponly]]]]]] )

// remember add www. if your site is always referenced by www. if not than just use yourdomain.com
setcookie("mc-pref", $prefs, time()+525600, '/', 'yourdomain.com');

 

Cookies can sometimes be very specific meaning they require a path and a domainname to work properly.

 

Also if you are working on LOCALHOST I would highly suggest looking at this:

http://www.aeonity.com/frost/php-setcookie-localhost-apache

 

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.