Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I'm using the following command to set cookies:
print "Set-Cookie: LOGIN_NAME=$NAME_CHOICE; expires=1d\n"; print "Set-Cookie: CITY=@infor[0]; expires=1d\n"; print "Set-Cookie: WALLPAPER=@infor[1]; expires=1d\n";

It works just fine until I close the browser. Is there a way to keep the cookies even after the brower is closed so the next browser that is opened can still read these cookies, until they expire 1 day later?

Thanks in advance for any assistance.

Replies are listed 'Best First'.
Re: Making Cookies Stick
by ccn (Vicar) on Aug 27, 2004 at 20:19 UTC

    You must provide proper format for 'expires' part of cookie. It's a full date like 'expires=Sat, 28-Aug-2004 20:16:30 GMT'

    You can make your task easier with CGI::Cookie

    P.S. a browser settings must allow permanent cookies also

Re: Making Cookies Stick
by dragonchild (Archbishop) on Aug 27, 2004 at 20:19 UTC
    use CGI's cookie() routine. It will do things no-one but Stein is aware of.
    use CGI qw( cookie ); print cookie( -name => 'LOGIN_NAME', -value => $NAME_CHOICE, -expires => '+1d', );

    And, so forth.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

    I shouldn't have to say this, but any code, unless otherwise stated, is untested

Re: Making Cookies Stick
by Fletch (Bishop) on Aug 27, 2004 at 23:23 UTC

    And on an unrelated note, @array[0] is wrong; you have a one element slice where you should be using $array[0].