Page 1 of 1

Cookie Problem

Posted: Mon Jan 05, 2004 6:44 am
by speedysven
I am trying to use PHP to create a cookie, I have the basic code working on my server. However, the issue arises when I try and run the code from the website the code is for. I think the issue is because the url forwards the domain to my server so the url is http://www.steverock.com but the server url is different.

Basically when I set the cookie on my server using the direct url it works fine and does everything it should, however, when I use the http://www.steverock.com url it sets a cookie but the cookie is deleted when the browser is closed.

Has anyone got any ideas on how to get round this??
Any help would be greatly appreciated.

Posted: Mon Jan 05, 2004 7:08 am
by Nay
You're probably setting a cookie like this:

Code: Select all

setcookie('thecookie', 'thevalue');

// but that will only last until the user closes the browsers, so u need to set the expiry time:

setcookie('thecookie', 'thevalue', time() + (60 * 60 * 24));
in that case, we added 24 hours as of the cookie was set, so it'll last for the next 24 hours.

-Nay