[SOLVED] Session fault tolerence

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mike_b2
Forum Newbie
Posts: 3
Joined: Wed Oct 06, 2004 2:03 am

Session fault tolerence

Post by mike_b2 »

I am trying to write my code so my sessions are able to run across two or more servers.

I want to do this using the session ID sotred in a cookie not using URL rewriting.

With that said can someone point me in the direction of a howto, code examples, and / or configuration requirements to do this.

I am using a load balancing router in fron tof the servers, so to the outside world this will look like the same ip address / hostname.

Thanks,
Mike :?:
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

[php_man]session_start[/php_man]() / [php_man]setcookie[/php_man]()

Is there a shared database between these 2 servers? If so, you can pass the session data through that, and just need the session id, which can then be passed in any standard fashion.
mike_b2
Forum Newbie
Posts: 3
Joined: Wed Oct 06, 2004 2:03 am

Post by mike_b2 »

Thanks for the reply.

Yes, there is a shared database, however I am a newbie to PHP and while looking at the session doc saw mention they could be shared but did not see it as out of the box explicitly. e.g. Do I need to be careful of duplicate session ID's., is there any exclusivity issues with the table etc.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the probability that the machines generate the same id is quite slim, but if you are concerned about it, you could (potentially) select a UUID from MySQL (4.1.2 or later), or create your own somewhat synchronized way through some interserver communication.

As for exclusivity to the table, probably not as well, but that depends on the type of table/database you are using.
djot
Forum Contributor
Posts: 313
Joined: Wed Jan 14, 2004 10:21 am
Location: planet earth
Contact:

Post by djot »

-
How about security, passing sessions or ids?

Btw., 1 login for 2 servers is called "single sign on".

djot
-
mike_b2
Forum Newbie
Posts: 3
Joined: Wed Oct 06, 2004 2:03 am

Thanks feyd that is what I was looking for<eom>

Post by mike_b2 »

Thanks feyd that is what I was looking for.

Mike
Post Reply