Click here to get back home

Session handling, login across all subdomains

 HomeNewsGroups | Search | About
 comp.lang.php    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Session handling, login across all subdomains Josh 07-25-2008
Get Chitika Premium
Posted by Josh on July 25, 2008, 1:16 pm
Please log in for more thread options
I run a Joomla website and am familiar with php in some but not all
aspects. Currently I am trying to find some solutions related to
session handling.

Am I correct in saying that "login" is kept in sessions? I can see
active sessions in my mysql database, but is that the only place this
information is stored? Sessions and cookies I know are related also,
but how specifically (session info stored in cookies?)?

Right now, when users login at example.com, and then visit
subdomain.example.com, they are not logged in at the subdomain. I am
trying to change this so that users logged in on the main site or any
subdomain are also logged in across all other subdomains and the main
site. I know sites like livejournal successfully accomplish this.

I have read some stuff about mod_rewrite solutions, but I don't think
this is really what I need. From what I can tell, the domain is stored
in a session, and I may need to generalize it somehow, but I don't
know how to test this.

Any ideas?

Posted by Chetan on July 25, 2008, 3:20 pm
Please log in for more thread options

> I run a Joomla website and am familiar with php in some but not all
> aspects. Currently I am trying to find some solutions related to
> session handling.
>
> Am I correct in saying that "login" is kept in sessions? I can see
> active sessions in my mysql database, but is that the only place this
> information is stored? Sessions and cookies I know are related also,
> but how specifically (session info stored in cookies?)?
>
> Right now, when users login at example.com, and then visit
> subdomain.example.com, they are not logged in at the subdomain. I am
> trying to change this so that users logged in on the main site or any
> subdomain are also logged in across all other subdomains and the main
> site. I know sites like livejournal successfully accomplish this.
>
> I have read some stuff about mod_rewrite solutions, but I don't think
> this is really what I need. From what I can tell, the domain is stored
> in a session, and I may need to generalize it somehow, but I don't
> know how to test this.
>
> Any ideas?
Besides the name of the session cookie and the place where the session
information is stored, both the sites also need to share the idea of who a
"user" is. That would generally mean that both the sites use the same database,
or at least the users information comes from the same table.

That might be question of setup or installing additional modules etc. I don't
know specifics of Joomla.

Chetan

Posted by Jerry Stuckle on July 25, 2008, 10:45 pm
Please log in for more thread options
Josh wrote:
> I run a Joomla website and am familiar with php in some but not all
> aspects. Currently I am trying to find some solutions related to
> session handling.
>
> Am I correct in saying that "login" is kept in sessions? I can see
> active sessions in my mysql database, but is that the only place this
> information is stored? Sessions and cookies I know are related also,
> but how specifically (session info stored in cookies?)?
>
> Right now, when users login at example.com, and then visit
> subdomain.example.com, they are not logged in at the subdomain. I am
> trying to change this so that users logged in on the main site or any
> subdomain are also logged in across all other subdomains and the main
> site. I know sites like livejournal successfully accomplish this.
>
> I have read some stuff about mod_rewrite solutions, but I don't think
> this is really what I need. From what I can tell, the domain is stored
> in a session, and I may need to generalize it somehow, but I don't
> know how to test this.
>
> Any ideas?
>

Your problem is the session id is kept in a cookie. However, the browser
will not normally send a cookie from one website to a different website.
And even though they are subdomains of the same domain, they are
different sites.

To get them to work with all of your subdomains, in your php.ini file set

session.cookie_domain = .example.com

where example.com is your main domain. The leading period is important.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================


Posted by C. (http://symcbean.blogspot.c on July 27, 2008, 10:24 am
Please log in for more thread options
> Josh wrote:
> > I run a Joomla website and am familiar with php in some but not all
> > aspects. Currently I am trying to find some solutions related to
> > session handling.
>
> > Am I correct in saying that "login" is kept in sessions? I can see
> > active sessions in my mysql database, but is that the only place this
> > information is stored? Sessions and cookies I know are related also,
> > but how specifically (session info stored in cookies?)?
>
> > Right now, when users login at example.com, and then visit
> > subdomain.example.com, they are not logged in at the subdomain. I am
> > trying to change this so that users logged in on the main site or any
> > subdomain are also logged in across all other subdomains and the main
> > site. I know sites like livejournal successfully accomplish this.
>
> > I have read some stuff about mod_rewrite solutions, but I don't think
> > this is really what I need. From what I can tell, the domain is stored
> > in a session, and I may need to generalize it somehow, but I don't
> > know how to test this.
>
> > Any ideas?
>
> Your problem is the session id is kept in a cookie. However, the browser
> will not normally send a cookie from one website to a different website.
> And even though they are subdomains of the same domain, they are
> different sites.
>
> To get them to work with all of your subdomains, in your php.ini file set
>
> session.cookie_domain = .example.com
>
> where example.com is your main domain. The leading period is important.
>

...but test it first - particularly with MSIE 8 and FF3.

A better solution might be to look at single sign on - or at least
rebinding the session id at runtime.

C.

Similar ThreadsPosted
Session across subdomains October 10, 2006, 3:37 am
Login lgout and login without closing session gives redirection error June 15, 2005, 5:54 pm
session handling problems October 13, 2004, 8:00 pm
session handling over HTTP August 12, 2005, 2:20 pm
Session handling with memcache - faster? December 6, 2005, 12:15 pm
session handling using classes n objects December 5, 2006, 5:11 am
Very unusual session handling problem. January 9, 2007, 7:16 am
HELP W/ PHP Session Login App January 26, 2005, 8:37 pm
How can I transmit session id in login php July 26, 2007, 1:25 am
simple session login problem October 16, 2004, 1:42 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap