in reply to Making CGI::Session Permanent

As mentioned use the expires setting of the cookie. Be sure though to add a timestamp to the basket table in the database so that after a year say you can empty out the dead items.

It would also be wise to check that the cookie is updated now and then so that it does not expire unexpectedly. Set the expire time to less than the db lifetime and you will be fine - as long as you update both the database and the cookie at the same time.

--tidiness is the memory loss of environmental mnemonics

Replies are listed 'Best First'.
Re: Re: Making CGI::Session Permanent
by oghran (Initiate) on Dec 10, 2003 at 11:14 UTC
    When you say cookie do you mean the session ? I've actually just tried setting the session expiry to 30 days from now using:
    $session->expire('+30d');
    This doesn't seem to have worked though and as soon as I close the browser, the cart is empty once again.

    Is there someway to set the expiry of the cookie specifically within CGI::Session other than $session->expire() ?

      Okay, nevermind. I've actually looked back at my code and realised I'm saving the session id as a cookie with CGI::Cookie. Ive set the expiry of that for 30 days and its working perfectly.

      Sometimes it pays to read your own code before posting.

      Thanks :)