1

Is there a way to make a php session span through my www.domain.com as well as sub.domain.com??? just using session_start() and $_SESSION['foo'] = "bar" does not work...any suggestions? the PHP manual does not say anything about it.

Thanks

4 Answers 4

2

you can try setting the cookie domain

ini_set("session.cookie_domain", ".domain.com");

this will set all sub domains within the domain.com to be see as the one domain

Sign up to request clarification or add additional context in comments.

Comments

2

The default session tracking in PHP relies on cookies (PHPSESSID, by default, if memory serves).

You can set the domain using session_set_cookie_param() (but you must do so before calling session_start(), I think) -- or you can set it in php.ini, or .htaccess like:

php_value session.cookie_domain ".domain.com"

Comments

1

Check out this question.

PHP: Cookie domain / subdomain control

Comments

1

I'm sure there are other answers, but you could use session_set_save_handler to store your sessions in a database. http://www.php.net/manual/en/function.session-set-save-handler.php

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.