Welcome to WebmasterWorld Guest from 54.163.35.238

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Alternate ways of organising sessions

I don't like cookies and query strings even less!

     

killroy

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

WebmasterWorld Senior Member 10+ Year Member



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

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

10+ Year Member



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

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

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

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

WebmasterWorld Senior Member 10+ Year Member



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

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

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

Featured Threads

Hot Threads This Week

Hot Threads This Month