0

I am building a site with a shopping cart which is stored in sessions like this:

if (!array_key_exists($pid, $_SESSION['cart'])) 
    {
        $_SESSION['cart'][$pid] = array(
            'itemId'=>$pid,
            'qty'=>0
        );  
    }

The issue is that the Sessions are expiring quickly, maybe 30 minutes. I would like to be able to keep the sessions for 1 day at least.

Is there any specific way for doing this?

BartoszKP
  • 34,786
  • 15
  • 102
  • 130
samyb8
  • 2,560
  • 10
  • 40
  • 68
  • 1
    I've always used this method and found it to be fine! http://stackoverflow.com/questions/520237/how-do-i-expire-a-php-session-after-30-minutes – emma.fn2 Apr 15 '13 at 22:10
  • You can check this link. Same issue like yours. http://stackoverflow.com/questions/4936207/php-session-expiring-too-early – Kevin Rave Apr 15 '13 at 22:14

1 Answers1

1

You should be able to extend the session by editing the following in php.ini:

; After this number of seconds, stored data will be seen as 'garbage' and ; cleaned up by the garbage collection process. ; http://php.net/session.gc-maxlifetime

session.gc_maxlifetime = 1440