[Chameleon] Session Time Out

Paul Spencer pspencer at dmsolutions.ca
Fri Jan 21 12:29:27 EST 2005


To expand on Jason's answer (for the curious), the KeepSessionAlive 
widget includes a 1x1 transparent pixel in the HTML.  The source of the 
image is a PHP script.  The widget works by using javascript timers to 
reload the image source every X seconds (600 in this example).  By 
reloading the image source, the browser reloads the PHP script that 
draws the image.  The PHP script also reloads the user's session, which 
updates the internal timestamp that PHP uses to determine if a session 
has expired (based on its timeout setting from php.ini - typically set 
to 30 mins).  When the application is next 'used' by the user, PHP will 
see the session as being last accessed X seconds ago rather than the 
real amount of time that has passed, thus preventing PHP from 
considering the session as expired.

This is important because every PHP script that is run ... from any user 
  and any page on the same server ... has a chance of triggering garbage 
collection, which is the process PHP uses to remove expired sessions 
from the server.  Without the KeepSessionAlive widget, if you leave an 
application open without doing anything to it for more than the timeout 
value set in php.ini, PHP will delete the associated session files and 
then when you do try to do something (after lunch ;)) Chameleon will 
tell you that the session has expired.

Cheers,

Paul

Jason Fournier wrote:
> Robin,
> 
> The 600 is the amount of time, in seconds, that the widget will refresh 
> the application's session.  The widget has this value because some 
> people change the session timeout value for their php installation.
> 
> The widget is self contained - you do not have to set anything else in 
> the application.  You can place the widget as stated in your app and it 
> should start working right away:
> 
> <cwc2 type="KeepSessionAlive" timeout="600" />
> 
> Thanks,
> Jason
> 
> 
> 
> Robin Brown wrote:
> 
>> Jason,
>>
>> What is the 600 for?  Does this indicate how often the widget 
>> refreshes or is this
>> supposed to match a timeout value somewhere else?  Also, do you mean I 
>> can put this
>> widget in my html template exactly the way you have it and I will no 
>> longer get the
>> "session timed out" message?
>>
>> Thanks for your help
>>
>> Robin
>>
>> Quoting Jason Fournier <jfournier at dmsolutions.ca>:
>>
>>
>>> Robin,
>>>
>>> It's actually dictated by PHP.  You can add the following widget to 
>>> your template to maintain the session:
>>>
>>> <cwc2 type="KeepSessionAlive" timeout="600" />
>>>
>>> The timeout value is in seconds.  This widget basically refreshes the 
>>> session so that it doesn't expire.
>>>
>>> Jason
>>>
>>>
>>>
>>> Robin Brown wrote:
>>>
>>>> Why does my session sometimes time out?  Is there a way to set how 
>>>> long it takes
>>>
>>>
>>> for
>>>
>>>> this to happen?  Is it Chameleon or Mapserver?
>>>>
>>>> Robin
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Chameleon mailing list
>>>> Chameleon at lists.maptools.org
>>>> http://lists.maptools.org/mailman/listinfo/chameleon
>>>>
>>>
>>> -- 
>>> _____________________________
>>>
>>>   Jason Fournier
>>>
>>>   DM Solutions Group Inc.
>>>   jfournier at dmsolutions.ca
>>>   www.dmsolutions.ca
>>>   613.565.5056 x18
>>>
>>> _______________________________________________
>>> Chameleon mailing list
>>> Chameleon at lists.maptools.org
>>> http://lists.maptools.org/mailman/listinfo/chameleon
>>>
>>
>> _______________________________________________
>> Chameleon mailing list
>> Chameleon at lists.maptools.org
>> http://lists.maptools.org/mailman/listinfo/chameleon
>>
> 

-- 
+-----------------------------------------------------------------+
|Paul Spencer                           pspencer at dmsolutions.ca   |
+-----------------------------------------------------------------+
|Applications & Software Development                              |
|DM Solutions Group Inc                 http://www.dmsolutions.ca/|
+-----------------------------------------------------------------+


More information about the Chameleon mailing list