Hi I am in a problem. I have a site Customermath.com. I have created a new subdomain on comlaint.customermath.com Here any one can come and post there complaint. I am also providing other service on customermath.com which need person to login. I want to maintain session between subdomain like if some one log in through customermath.com then he should not be asked to log in on complaint.customermath.com and vis-versa. Please help me if any one can.
Try to upload a .htaccess file to your site root and subdomain root with the following content: php_value session.cookie_domain ".customermath.com"
Hi elisa thanks but this code is not working. If you can explain a little more it will be helpful. I have try but it show internal server error 500.
Hmm.. I advise you to contact your hosting provider, telling them that you can't set the value with and .htaccess (got same problem with URL-rewriting on one of my hosts and it returned an 505)
Hi elias I have talk to them they told me that I can put php.ini my domain root and it will work Now if you have any solution then please tell it will be very kind of you.
You need to find a php.ini and edit it. Maybe ask you host, if they could send their standard php.ini to you. After they've done that (or you've found one), you'll need to find the line where it says: session.cookie_domain, and change it's value to session.cookie_domain = ".customermath.com" Then upload to your root, and try again.
thanks elisa I have follow the same procedure and it works. Now its maintaining the session through out the sub domains. Thanks for your timely help.
Hi Elisa, My VB 4 website has same problem as well. When user has logged in, they can view session info under www.mydomain.com. However, if they change URL to forum.mydomain.com. The session info is disappeared. I followed your advice in this post, set the php.ini session.cookie_domain = .mydomain.com or session.cookie_domain = ".mydomain.com" But it still doesn't work. Any other aspects should be set in php.ini? Thanks
The setcookie function allows you to do that without having to go and edit the php.ini file. Look for the setcookie function on VB4 and change it to something like this: /* expire in 1 hour */ setcookie("TestCookie", "TestValue", time()+3600, "/", ".example.com", 1); PHP: This will set the cookie/session for all subdomains.
jobBole: Remember to restart your server after changing the php.ini - otherwise, the server won't recognize the new settings. A second solution is to do it by .htaccess with php_value session.cookie_domain ".domain.com". You could also consider throwing session_set_cookie_params() before session_start(). Using that function you can set the domain allowing the session cookie to be used across subdomains. http://php.net/manual/en/function.session-set-cookie-params.php
Hi All, Could you please suggest me how to do the above things in java. As I am also facing the same issue and wanted to share a common session in domain and sub domains website. Please reply me Vikram
This can be done via the php.ini file. You need to save a copy of php.ini the root directory of your website. Then edit the line with the following code: session.cookie_domain = Change this to as below: session.cookie_domain = “.<domain name>”; For example if your domain is abc.com and subdomain is test.abc.com you will need to replace the domain name above with abc.com.
You don't need to edit your php.ini file. vBulletin has cookie specific settings in the admin CP, you can change it there.