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.
Cookie Problem
Moderator: General Moderators
You're probably setting a cookie like this:
in that case, we added 24 hours as of the cookie was set, so it'll last for the next 24 hours.
-Nay
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));-Nay