Michdd Posted November 21, 2008 Share Posted November 21, 2008 I have a problem keeping my session going when going to a different subdomain, how do I fix this? Link to comment https://forums.phpfreaks.com/topic/133709-session-problems/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 21, 2008 Share Posted November 21, 2008 http://us2.php.net/manual/en/session.configuration.php#ini.session.cookie-domain Link to comment https://forums.phpfreaks.com/topic/133709-session-problems/#findComment-695791 Share on other sites More sharing options...
Michdd Posted November 21, 2008 Author Share Posted November 21, 2008 http://us2.php.net/manual/en/session.configuration.php#ini.session.cookie-domain http://us2.php.net/manual/en/function.session-set-cookie-params.php more specifically is what I would need to use right? And do I need to set all the values in that function? Or can I just use the one I need? Also, if I want to set it to a subdomain like... something.example.com how would I do that? Sorry, I'm kinda new to sessions. Link to comment https://forums.phpfreaks.com/topic/133709-session-problems/#findComment-695799 Share on other sites More sharing options...
PFMaBiSmAd Posted November 21, 2008 Share Posted November 21, 2008 In order to use the session_set_cookie_params() function to set the domain (which is really specifying the hostname/subdomain because cookies are already domain specific), you would need to also set the lifetime and path parameters too. You can directly set just the session.cookie_domain using an ini_set() statement. You can also globally set session.cookie_domain in the master php.ini, a .htaccess file when php is running as an Apache module, or in a local php.ini when php is running as a CGI application. Link to comment https://forums.phpfreaks.com/topic/133709-session-problems/#findComment-695814 Share on other sites More sharing options...
Michdd Posted November 21, 2008 Author Share Posted November 21, 2008 In order to use the session_set_cookie_params() function to set the domain (which is really specifying the hostname/subdomain because cookies are already domain specific), you would need to also set the lifetime and path parameters too. You can directly set just the session.cookie_domain using an ini_set() statement. You can also globally set session.cookie_domain in the master php.ini, a .htaccess file when php is running as an Apache module, or in a local php.ini when php is running as a CGI application. Sorry if I'm making this hard. What exactly would I need to set to set the domain so it'll work on my domain/subdomain? Link to comment https://forums.phpfreaks.com/topic/133709-session-problems/#findComment-695855 Share on other sites More sharing options...
Michdd Posted November 21, 2008 Author Share Posted November 21, 2008 I tried this: session_set_cookie_params(30 * 60, "/", "theforbiddengates.net"); And it's not working, I'm trying to get it to work for a something.theforbiddengates.net Link to comment https://forums.phpfreaks.com/topic/133709-session-problems/#findComment-695904 Share on other sites More sharing options...
PFMaBiSmAd Posted November 22, 2008 Share Posted November 22, 2008 domain Cookie domain, for example 'www.php.net'. To make cookies visable on all subdomains then the domain must be prefixed with a dot like '.php.net'. Link to comment https://forums.phpfreaks.com/topic/133709-session-problems/#findComment-695919 Share on other sites More sharing options...
Michdd Posted November 22, 2008 Author Share Posted November 22, 2008 domain Cookie domain, for example 'www.php.net'. To make cookies visable on all subdomains then the domain must be prefixed with a dot like '.php.net'. session_set_cookie_params(30 * 60, "/", ".theforbiddengates.net"); Doesn't work either, I put it above the start_session(); in my files, is that the right place? Link to comment https://forums.phpfreaks.com/topic/133709-session-problems/#findComment-695929 Share on other sites More sharing options...
PFMaBiSmAd Posted November 22, 2008 Share Posted November 22, 2008 The previous code has set a session cookie that will last 30 minutes. That cookie would need to be replaced by one containing the new settings before you would see any effect. Try closing your browser and revisiting your page. That line of code must be executed before every session_start(). Executing a single session_start() without doing that will cause a cookie to be set using the default/php.ini settings. Link to comment https://forums.phpfreaks.com/topic/133709-session-problems/#findComment-695938 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.