Sessioons and Logging in to multiple sites?

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
User avatar
mchaggis
Forum Contributor
Posts: 150
Joined: Mon Mar 24, 2003 10:31 am
Location: UK

Sessioons and Logging in to multiple sites?

Post by mchaggis »

Hi,

I was wondering if there was a way to allow users to log into multiple sites at once using sessions.

It is just 2 urls at the moment and they are on the same server, so I have been wondering it it's possible to trick php into sharing the sessions (or session files) between the to sites?
phpfreak
Forum Commoner
Posts: 30
Joined: Fri Mar 21, 2003 10:28 am
Location: New Jersey,USA
Contact:

Post by phpfreak »

I think the best solution would be to store the usernames and session created on them in a text file and then by having your open_basedir=on(if it is in the same server but different directory) and your allow_url_fopen=on(if the url of the text file is in other protocol),you can access this file and give the user the permissions to use any directory depending on the sessions listed in the text file. then you can use the fopen function to write the session to the text files or destroy them from the text files.
User avatar
mchaggis
Forum Contributor
Posts: 150
Joined: Mon Mar 24, 2003 10:31 am
Location: UK

Post by mchaggis »

I think i see... but how would i know it was the right user?

I theory, it seems a quite simple idea, but in practice i need to pass a cookie that can be read by both sites that contains session id and thus the sharing of files/sessions works.

Hmmm have a few ideas....
User avatar
mchaggis
Forum Contributor
Posts: 150
Joined: Mon Mar 24, 2003 10:31 am
Location: UK

Post by mchaggis »

Ok, half of the problem solved...

Two option have presented... One was in one of someones posts to the PHP manual (doh!)..

For sites that share same domain:

Code: Select all

session_set_cookie_params( time()+9999999, "", ".domain.com");
Ooo I wonder what would happen if I put .com or .uk for the domain :?:

The second is playing with the setcookie function and setting a cookie for every domain I want the session to work for
Post Reply