NYCPHP Meetup

NYPHP.org

[nycphp-talk] Keep login on two sites simultaneously by just login in any of the two sites..

Anirudh Zala arzala at gmail.com
Wed Sep 12 07:39:37 EDT 2007


On Wednesday 12 Sep 2007 15:58:38 Rahmin Pavlovic wrote:
> Aniesh joseph wrote:
> > Hello,
> >
> > Is it possible to share the session in two sites? I have two sites both
> > of them having same contents(login id & password) in the database.. So
> > someone login in siteA, possible to login in siteB automatically?
>
> I like to keep a sort of "bridge" table for things like this.
>
> Say, user logs into site A, and their session id -- or some hash of their
> personal data -- gets stored in the bridge table with a timestamp (and user
> id, or whatever else you want to link up to).
>
> If you drive content from one site to another, you could append their
> session id to the URL, and lookup that user on site B, within a given
> timeframe (say, 30min since the bridge timestamp was inserted).
>
> If the user/pass info is exactly the same on both sites, you could store a
> hash of that in the bridge table (as opposed to the session).
>
> If logins to site B are sensitive, you could include a counter in the
> bridge table to only allow one concurrent login.

If you are using session cookies (which is used on most of implementations) 
then you can share it among multiple sites if base domain is same. For 
example if siteA is http://www.example.com and siteB is 
http://subsite.example.com then you can read session cookies of 1 site from 
another (and vice versa, provided that you set cookies the way it is 
required) hence no need to store data into table or to pass any hash or 
string into URL.

Yahoo uses this technique because structure of it's services are like  
autos.yahoo.com, mail.yahoo.com etc. Hence they can share same cookies on all 
services as main domain (yahoo.com) is same.

This method can work only if you have 2 websites with above domain name 
pattern. But if you have 2 different domains then method shown by Rahmin is 
must.

>
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php





More information about the talk mailing list