4

Is there any way to make common session for multiple domains on the same server, for sub domains we are using session_cookie so i am able to make common session for sub domains.

please help!!!

Vinod Puliyadi
  • 225
  • 1
  • 3
  • 14

2 Answers2

2

You should store you session data in the database, this is accomplished by "rerouting" the save handler to your DB saving functions, like this:

session_set_save_handler ( callback $open , callback $close , callback $read , 
                           callback $write , callback $destroy , callback $gc )

The callbacks are obvious. if you make a quick search in Google you'll find a bunch of tutorials on the matter, so you won't have to write it from scratch. Also, if you are going to implement your own session class, be sure to read Chriss Shiflett's article "The Truth about sessions"

David Conde
  • 4,631
  • 2
  • 35
  • 48
  • I don't see how this helps. Sure, all your data is stored in the database, which can be retrieved from multiple domains, but then how do you pass the session ID to the other domains? – andrewtweber May 25 '11 at 16:29
0

Below links may help you.

How do I maintain PHP sessions across multiple domains on the same server?

http://www.daniweb.com/forums/thread180252.html

The important thing is that you should have common place for session storage which will be accessed by all domains like database as suggested by david

Community
  • 1
  • 1
Nik
  • 4,015
  • 3
  • 20
  • 16