Re: [PHP] $_SESSION variable gets lost on FORM action



David Giragosian wrote:
On 1/16/07, Nuno Oliveira <dreasi0n.php.net@xxxxxxxxx> wrote:

Hi,

I'm working on a website and one of the features that I've implemented
so far is the user timeout.

Every time that a user browses to a different page, the variable named
$_SESSION['user']['lastactive'] is updated to the current time.

However, before that, my PHP scripts check if the session for this user
had timed out or not...

The script that checks that is named "session.php" and it is included in
every file. If it detects a timeout, it sets a variable
$_SESSION['form']['errors'] to a string ('Your session has expired...
Bla, bla, bla...') and then redirects to the login.php and the user will
see that he his being asked to login again for the reason displayed.

Everything works great except in one situation... If the timeout period
happens when the user is filling a form, the action that it executes
(process.php) will also include session.php and it sets the error string
but when it redirects to login.php the $_SESSION['form']['errors']
variable is empty...


You must be unsetting the individual $_SESSION['form']['errors'] variable
or the entire $_SESSION array somewhere in there.

David


Hi Davis, thanks for the reply.

I think that I've found the problem... But if you (or anyone else) can confirm I would appreciate.

Sometimes in my code I use the Header('Location: index.php?var=value'); and I've found out (I think) that when one of these headers are executed by PHP, the rest of the script gets executed.


I'm thinking that this is the problem because I've eliminated all the occurrences where the SESSION var was cleared until only one exists and it was after a Location Header.

I've put an exit(); after the header and the problem was gone... :)

Is this the correct PHP/HTML behavior or is there another problem? Am I supposed to put an exit(); after a header "Location" to make sure that no more code gets executed?

Thanks
.



Relevant Pages

  • Re: Application Pool timouts.
    ... a) From what i understand, the application pool timeout is the timeout for ... an idle session which is created by a browser. ... is idle for 20 minutes or longer the problems occur. ... Application Pool's w3wp.exe process to be shutdown by IIS when no requests ...
    (microsoft.public.inetserver.iis.security)
  • Re: How do I change the session timeout?
    ... A session will last for as long a period as you set in ... That's set in the forms timeout property. ... You will see that the logged-in period changes to match the number of minutes you specify. ... Microsoft MSDN Online Support Lead ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: SQLCommandTimeout
    ... to set the value for the session? ... designer) you can set the Command Timeout value there. ... I am just using the DataSource, configured to use my stored procedure, ... I found out about the SQLCommandTimeout Property that can be used to ...
    (microsoft.public.dotnet.general)
  • RE: Remote webspace logging off.
    ... their session after a certain amount of time. ... Please check the following settings: ... Restart the IIS Service or restart the SBS Server. ... Remote Web Workplace timeout: ...
    (microsoft.public.windows.server.sbs)
  • Re: Clients Losing Session
    ... the browser will also timeout. ... report, then have the page poll for the results. ... | minutes the session terminates. ... | In addition to this when the session terminates for the user. ...
    (microsoft.public.dotnet.framework.aspnet)