my sessions only work with a sub-domain, e.g. www. ,and do not work without that sub-domain.
For example, when a user is logged in.
If the address is n
If you want the php session to work all your subdomains, you must change cookie_domain
option. Type this to top of your script:
ini_set('session.cookie_domain', '.example.com' );
i solved this probem use this code
session_name("name");
ini_set ("session.cookie_domain", '.domain.com') ;
session_set_cookie_params(0, '/', '.domain.com');
session_start();
www.domain.com
and domain.com
are NOT the same website. They are the mirror copy of each other
For this reason, cookies set on domain.com
will NOT be used on www.domain.com
and vice-verse, because it would be unsafe to assume they are the same thing.
You can override this behavior to some extent by allowing the session cookie to work on all subdomains as well as the main domain by setting the php.ini setting session.cookie_domain
to .domain.com