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
https://forums.phpfreaks.com/topic/51582-php-cookies-yes-ive-read-the-tutorials/
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.

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

 

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.