Storing Plog Sessions in Database

Storing Plog Sessions in Database

Postby edteach on Fri May 20, 2005 8:53 am

I have modified the sessionmanager.class.php file to allow plog to store sessions in the database. This is useful if one wants to implement who's online functionality because it makes it trivial to find out exactly who or what is browsing your plog site. The nice thing about this is that it only requires that a table be added to the database to store the sessions and that this one file is modified. I suppose if someone wanted to they could create a configuration option to select whether to use database sessions or file system sessions.

If anyone is interested let me know.
edteach
 
Posts: 77
Joined: Mon Apr 18, 2005 12:01 pm

Postby jondaley on Fri May 20, 2005 10:04 am

Do the sessions get erased properly, ie. within a reasonable amount of time after the user leaves the site? I haven't looked into it, but another project that I saw ended up with tons of old sessions in their database, and I had to manually clean them with a cron job. Is there an easier way?
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Postby edteach on Fri May 20, 2005 10:15 am

Yeah, this technique just ties into PHP's own session handling by telling php to use your own session handling functions unstead of PHP's.

By setting "session.gc_maxlifetime" you tell PHP how long a session should live for and by setting 'session.gc_probability' (to 100) you tell essentially tell PHP to run the session garbage collection function every time a session is accessed.

What's really nice about writing your own session handler is that in theory you can tell your session handler to set properties that would be expected by other applications like PHPBB. I don't know if this would work yet. I haven't tried it but I don't see why it wouldn't. Then you would just have to tell the other app to call its session the same as your plog session. It should allow you to have a single login (through Plog) for any other apps you install in your site.
edteach
 
Posts: 77
Joined: Mon Apr 18, 2005 12:01 pm

Postby Ameng on Mon Jun 13, 2005 10:37 pm

Hi, edteach

I am interested in this because it will bring more flexibility.

Could you share this to us.
Ameng
 

Postby phunkphorce on Tue Jun 14, 2005 1:55 am

We are going to integrate this with plog 1.1, as soon as we have the time... I've got his code :)
phunkphorce
Lifetype Expert
 
Posts: 9028
Joined: Mon Aug 25, 2003 6:34 am
Location: Suomessa

Postby markwu on Tue Jun 14, 2005 5:10 am

I sounds great ... :o

Mark
markwu
Lifetype Expert
 
Posts: 920
Joined: Wed Mar 31, 2004 1:59 pm

Postby Ameng on Wed Jun 15, 2005 10:57 pm

So good!
Ameng
 

Postby phunkphorce on Thu Jun 16, 2005 3:12 am

Just be aware that database sessions are a bit slower than normal file sessions... But your mileage may vary, of course :)
phunkphorce
Lifetype Expert
 
Posts: 9028
Joined: Mon Aug 25, 2003 6:34 am
Location: Suomessa

Postby mad93 on Wed Feb 01, 2006 5:15 pm

This is a great notice o.0

I'm having enormous problems with the sessions...
mad93
 
Posts: 5
Joined: Wed Feb 01, 2006 5:11 pm

Re: Storing Plog Sessions in Database

Postby bet0x on Fri May 02, 2008 2:17 am

WHow is that hack? :D
bet0x was here ^^
bet0x
 
Posts: 5
Joined: Fri Nov 16, 2007 5:14 pm
Location: Rosario, Santa Fe


Return to General Plugin Development

cron