automatic logout before SESSION end

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

    automatic logout before SESSION end

    Hello there,

    On my site people have to log in and automatically start a session. An
    authorized login grants access to other pages and MySQL data.
    However when the user waits to long, the server ends the session, without a
    proper logout. The user can't see that he is logged out, hits a button and
    gets
    mutiple errors because MySQL is no longer available.
    Is there a way to to warn the user a minute before the session is ended?
    I just read, the session time is set in session.gc_maxl ifetime in php.ini.
    So I
    can let a timer run along with this time and warn the user, but doesn't the
    server returns a signal before the session is ended that I can use to alert
    the user or in any case can trigger a proper logout?

    thanks, Chris


  • Gordon Burditt

    #2
    Re: automatic logout before SESSION end

    >On my site people have to log in and automatically start a session. An[color=blue]
    >authorized login grants access to other pages and MySQL data.
    >However when the user waits to long,
    >the server ends the session,[/color]

    *WHICH* server ends the *WHAT KIND OF* session? I presume you mean
    MySQL server and the connection to it, not http server and PHP
    $_SESSION, here.
    [color=blue]
    >without a
    >proper logout. The user can't see that he is logged out, hits a button and
    >gets
    >mutiple errors because MySQL is no longer available.[/color]

    I'd like to suggest re-establishing the MySQL connection, if possible,
    if it has timed out. Then there's no need to warn the user.
    [color=blue]
    >Is there a way to to warn the user a minute before the session is ended?[/color]

    PHP runs server side. You can't push data to the browser. You could
    tell the user his session has timed out, but it's a little late at
    that point. Javascript is Turned Off(tm).
    [color=blue]
    >I just read, the session time is set in session.gc_maxl ifetime in php.ini.[/color]

    The maximum idle time for a MySQL connection is set in my.cnf or
    a server default.

    Gordon L. Burditt

    Comment

    • Chris Stegeman

      #3
      Re: automatic logout before SESSION end

      Thanks Gordon, but it is in fact the http server (apache) that ends the PHP
      $_SESSION!
      The SQL errors occur because the user has no rights anymore to connect to
      the MySQL server when the $_SESSION has ended.
      I was hoping the http server would send some kind of alert, before ending
      the PHP $_SESSION

      Chris

      "Gordon Burditt" <gordonb.vg7c9@ burditt.org> schreef in bericht
      news:11lg44vh7f ha329@corp.supe rnews.com...[color=blue][color=green]
      > >On my site people have to log in and automatically start a session. An
      >>authorized login grants access to other pages and MySQL data.
      >>However when the user waits to long,
      >>the server ends the session,[/color]
      >
      > *WHICH* server ends the *WHAT KIND OF* session? I presume you mean
      > MySQL server and the connection to it, not http server and PHP
      > $_SESSION, here.
      >[color=green]
      >>without a
      >>proper logout. The user can't see that he is logged out, hits a button and
      >>gets
      >>mutiple errors because MySQL is no longer available.[/color]
      >
      > I'd like to suggest re-establishing the MySQL connection, if possible,
      > if it has timed out. Then there's no need to warn the user.
      >[color=green]
      >>Is there a way to to warn the user a minute before the session is ended?[/color]
      >
      > PHP runs server side. You can't push data to the browser. You could
      > tell the user his session has timed out, but it's a little late at
      > that point. Javascript is Turned Off(tm).
      >[color=green]
      >>I just read, the session time is set in session.gc_maxl ifetime in php.ini.[/color]
      >
      > The maximum idle time for a MySQL connection is set in my.cnf or
      > a server default.
      >
      > Gordon L. Burditt[/color]


      Comment

      • Ian B

        #4
        Re: automatic logout before SESSION end

        You could use a javascript timer to either keep the session alive, or
        to check the idle time.

        Ian

        Comment

        • ijsaunders@gmail.com

          #5
          Re: automatic logout before SESSION end

          On all session protected bages, create a function checklogon at the top
          of the page. If the logon fails then redirect them back to the logon
          screen (but perhaps pass the page they were on in the querystring, to
          be used in the login script to redirect them back again)? I assume you
          are checking the logon at some point on the secure pages anyway?

          hope this helps

          Cheers

          Ian


          Comment

          Working...