SESSION timeout using time()

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

    SESSION timeout using time()

    I don't have access to the php.ini on my hosting provider's shared server
    and don't want to rely on cookies, so I'm wondering if this a reliable way
    to timeout a session:

    [login page]
    if (credentials are valid)
    {
    $_SESSION['timeout'] = time();
    redirect to url
    }

    [redirect page]
    if ($_SESSION['timeout'] > (time() - 300))
    {
    echo "You are logged in."
    }
    else
    {
    echo "Your session has timed out."
    }

    Seems to work - but I'm new to php... am I'm missing something?

    Thanks in advance.


  • Alvaro G. Vicario

    #2
    Re: SESSION timeout using time()

    *** deko escribió/wrote (Fri, 11 Mar 2005 21:08:41 GMT):[color=blue]
    > I don't have access to the php.ini on my hosting provider's shared server
    > and don't want to rely on cookies, so I'm wondering if this a reliable way
    > to timeout a session:[/color]
    [...][color=blue]
    > if ($_SESSION['timeout'] > (time() - 300))[/color]
    [...][color=blue]
    > Seems to work - but I'm new to php... am I'm missing something?[/color]

    It seems correct. Since you are always using the same clock (the server
    one) there should be no problem.



    --
    -+ Álvaro G. Vicario - Burgos, Spain
    +- http://www.demogracia.com (la web de humor barnizada para la intemperie)
    ++ Manda tus dudas al grupo, no a mi buzón
    -+ Send your questions to the group, not to my mailbox
    --

    Comment

    • deko

      #3
      Re: SESSION timeout using time()

      > It seems correct. Since you are always using the same clock (the server[color=blue]
      > one) there should be no problem.[/color]

      Thanks for the reply. A second set of eyes always helps.


      Comment

      Working...