NYCPHP Meetup

NYPHP.org

[nycphp-talk] Dual session operation question

Dan Cech dcech at phpwerx.net
Thu Feb 22 10:58:38 EST 2007


Cliff Hirsch wrote:
> I think I know the answer to this, unfortunately, but I¹ll throw it out to
> the group.
> 
> Is there any way to work with two session IDs and session handlers in one
> script?
> 
> My main site uses one session ID and the standard session functions. My
> commercial shopping cart uses a different session id and a custom mysql
> session handler. To carry login state between the two modules, I need access
> to both sessions. Or I need to merge the two session mechanisms into one.
> Neither approach sounds very enticing.
> 
> My previous developer used curl to perform a login ³loopback² to the
> shopping cart. Seems wasteful to me. Plus this assumes each script uses
> identical encryption schemes. His solution was to disable password
> encryption!
> 
> Any thoughts?

The simplest way would probably be something like:


session_name('SESS1');
session_start();

...

session_write_close();

...

session_name('SESS2');
session_start();

...

session_write_close();


I guess you could manipulate the session files directly if you felt like
reimplementing the session read/write code in php.

Dan



More information about the talk mailing list