Jump to content

Session problems.


Michdd

Recommended Posts

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

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

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.