开发者

domain -> subdomain - passing session data

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.开发者_C百科co.uk not still not working. Is there anything else that needs changing?

Regards, me.


in your htacces file

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

and you're done


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.


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


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.


This simple code will help you a lot, Just give it a try.it will work 100%.

<?php 
session_set_cookie_params(0, '/', '.domain.co.uk'); 
session_start(); 
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜