session expires to soon in php

Posted by user1669425 on Stack Overflow See other posts from Stack Overflow or by user1669425
Published on 2012-09-13T17:57:02Z Indexed on 2012/09/13 21:38 UTC
Read the original article Hit count: 121

Filed under:

I want to extend a session time so that a session variable does not expire until after 12 hours. Problem is that after 24 minutes (default time for a session until it expires) of inactivity it still expires the session and hence gives me undefined indexes for those SESSION variables.

What else do I need to do in the code below in order to be able to extend the sessions so that it does not expire on its own until 12 hours has passed:

    <?php
        ini_set('session.gc_maxlifetime',12*60*60);
ini_set('session.cookie_lifetime',12*60*60);
        phpinfo();              
        session_start();

    ....//rest of code below

        ?>

in phpinfo() it states this below for gc_maxlifetime:

                           Local Value  Master Value
session.gc_maxlifetime       43200        1440
session.cookie_lifetime      43200          0

© Stack Overflow or respective owner

Related posts about php