[horde] Re: horde sessionhandler

Andrew Morgan morgan at orst.edu
Fri Apr 22 08:53:19 PDT 2005

On Fri, 22 Apr 2005, Kevin Konowalec wrote:

> Well I gave it a try... but this is what I get:
> PHP Notice:  Undefined offset:  4 in /tmp/test.php on line 22
> <pre>
> Array
> (
>    [hordeMessageStacks] => Array
>        (
>            [javascript] => Array
>                (
>                )
>            [status] =>
>        )
>    [horde_language] => en_US
> )
> </pre>

What does the raw serialized data look like at that point?  Once you 
understand the serialized data format, you can figure out why it is 
tossing an error on that spot.  It may also help to put a print_r($vars) 
in the unserializesession() function so you can see what it is trying to 

> I just cut n pasted your code exactly.   Line 22 is "for($i = 0; $vars[$i]; 
> $i++) {"
> So then I added a while loop in case there was more than one entry kicking 
> around.  Sure enough it worked.  There appeared to be a bunch of table 
> entries but only one authenticated user...
> So now how can I filter the query based on a field in the serialized data?  I 
> don't want to have to parse the junk fields as they seem to break the script 
> (as above) so how can i get only genuine authenticated users?

I cheat and just have a script that calls:

SELECT count(*) FROM horde_sessionhandler
WHERE session_data LIKE '%authenticated%'

The count seems to be the same as what I get from parsing it out anyways.

> Also, one of the fields is:
> [timestamp] => 1114117500
> Is that the time of login?  What format is it?  I don't seem to see any 
> fields there that show idle time - do you know where that might be?

If I understand the code correctly, 'timestamp' is the last time that 
session was updated (the last time the user clicked on something), in unix 
time format (seconds since Jan 1, 1970).  You can figure out the idle time 
pretty simply using time() - timestamp, which will give you the number of 
seconds idle.


More information about the horde mailing list