Permanent Cookies

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
daniworldwide
Forum Newbie
Posts: 14
Joined: Mon May 26, 2003 12:30 pm
Location: Colorado

Permanent Cookies

Post by daniworldwide »

I was wondering how to set a permanent cookie on someone's computer.

Code: Select all

<?php
setcookie("mid",$mid,time()+3600,"/",".site.com",0);


?>
I have that, but how do I get it so its not 3600 seconds long, (1 hour), but forever? I deleted +3600 but that did not work, I got an error.

Thanks, -Dani 8O
qartis
Forum Contributor
Posts: 271
Joined: Sat Dec 14, 2002 4:43 pm
Location: BC, Canada
Contact:

Post by qartis »

Without the 'time' argument, cookies only last until the browser is exited. Your main option is to set the cookie lifetime to a larger number, like a year or two.
RTT
Forum Commoner
Posts: 38
Joined: Thu Jul 17, 2003 10:22 am
Location: Wolverhampton, UK
Contact:

Post by RTT »

Just set time()+31536000*n

where n is the number of years you want the cookie to be set for
Post Reply