views:

240

answers:

5

Howdy, having a little trouble here. I have domain.co.uk setting a session. When I click on a link on domain.co.uk to go to sub.domain.co.uk the session is not being read.

I have altered session.cookie_domain to .domain.co.uk not still not working. Is there anything else that needs changing?

Regards, me.

+1  A: 

You should take a look at: http://stackoverflow.com/questions/1064243/php-sessions-across-sub-domains

Lizard
I have already looked at that and have session_set_cookie_params(0, '/', '.domain.co.uk'); in the page.
Phil Jackson
I have one main page which includes files depending on variables and whether it is a subdomain ( using wildcard subs ).
Phil Jackson
A: 

Information about session ID stored in cookies. subdomain can`t read cookie if it is set by main domain. See information about session_name & setcookie and session_id() php functions. Or store session ids somewhere else (e.g. mysql database) P.S.: Sorry for my english.

GOsha
A: 

I agree with GOsha,

I do all my session handover by submitting form data or storing in SQL. Then recreate your session within the new domain environment.

I'm not 100% sure if there is an easier way?

Not sure if that helps.

Shane

Shane
samuelf
+1  A: 

in your htacces file

php_value session.cookie_domain ".domain.co.uk"

and you're done

Dobiatowski
A: 

Session data is stored in a cookie and if your on the domain google.com then only the domain google.com can access the cookie session data such as username or the session ID.

dev.google.com can't access the cookies for google.com and this means that a user logged into google.com won't be logged in when they go to dev.google.com. That is unless there is some mechanism such as passing the session ID in the query string to dev.google.com.

Paul Mendoza