Sessions and expiring cookies

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Derek Fountain

    #1

    Sessions and expiring cookies

    I set my session parameter so the session is a few minutes long, and if the
    user goes inactive for that period the session expires. Two questions:

    1) What mechanism actually expires the session? That is, what says "hang on,
    the time limit has passed, so that's no longer valid"? It can't be the
    browser, since that might be subverted or buggy. So does a browser send an
    expired cookie value anyway and trust the website to spot it has expired?

    2) How do I tell in my PHP that a session has expired? My code has a
    start_session() at the top, and uses of $_SESSION[xxx] underneath, but
    somewhere I should be checking that the session hasn't expired, shouldn't
    I? Or maybe start_session() does that for me somehow?

    --
    The email address used to post is a spam pit. Contact me at
    http://www.derekfountain.org : <a
    href="http://www.derekfounta in.org/">Derek Fountain</a>
  • R. Rajesh Jeba Anbiah

    #2
    Re: Sessions and expiring cookies

    Derek Fountain wrote:[color=blue]
    > I set my session parameter so the session is a few minutes long, and[/color]
    if the[color=blue]
    > user goes inactive for that period the session expires. Two[/color]
    questions:[color=blue]
    >
    > 1) What mechanism actually expires the session?[/color]

    session.gc_maxl ifetime <http://in2.php.net/session>
    [color=blue]
    > 2) How do I tell in my PHP that a session has expired?[/color]

    Check if the set/expected variable is in the $_SESSION array.

    --
    <?php echo 'Just another PHP saint'; ?>
    Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

    Comment

    Working...