homepage Welcome to WebmasterWorld Guest from 54.198.224.121
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Website
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Alternate ways of organising sessions
I don't like cookies and query strings even less!
killroy




msg:1308741
 11:21 am on Mar 28, 2005 (gmt 0)

I've recently joined the php crowd and have until now been working with my own systems.

In my old system sessions where recorded in a database usign a combination of user_agent, IP and a timeout to follow a visitor around the site, trying to avout proxy and NAT issues. Not a perfect system, but good enough for most purposes and more robust then cookies and less intrusive then query strings.

Could I use PHP session variables using my own session tracking mechanism? In other words, can I get my session ID from my database and forward it to the PHP session handler and access ressources from that session?

I want to take advantage of the resource savings that come with storing things like database connections and file handles in sessions variables.

How can I get the current session ID and how can I set it?

SN

 

GreenLeaf




msg:1308742
 3:06 pm on Mar 28, 2005 (gmt 0)

You need a custom session handler. Take a look at some ready examples: at Zend (http://www.zend.com/zend/spotlight/code-gallery-wade8.php) or DB_eSession (search for this term at Google) class.

coopster




msg:1308743
 9:39 pm on Mar 28, 2005 (gmt 0)

Outside of cookies or the query string about your only other option is to embed the session id in a hidden form variable. Somehow you have to make the connection/relation when using HTTP. Personally, I prefer using cookies.

Anyway, the zend tutorial mentioned is a decent read and can be found on the PHP manual page for session_set_save_handler() [php.net].

killroy




msg:1308744
 10:06 pm on Mar 28, 2005 (gmt 0)

You misunderstood. I HAVE the method of keeping track of a session, using a database and a combination of IP/user_agent and timeout.

What I need is a way of injecting my own sessionid into the php session system.

Something like getNewSessionID(), and LoadSessionWithThisID() if you know what I mean?

SN

coopster




msg:1308745
 10:10 pm on Mar 28, 2005 (gmt 0)

Well, if the method being used is a cookie you could assign the session_name() [php.net] before you start the session.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved