简体   繁体   中英

PHP Session gets destroyed on Subdomain

I'm trying to create a login system for my website. I got the session thing all set up and stuff. The user stays logged in on www.myhomepage.tld and it is displayed correctly everywhere.

However, as soon as I try to access the session from anysubdomain.myhomepage.tld, it gets destroyed instantly. The login indicator does not say the user is logged in, and when I return to www.myhomepage.tld, the user is no longer logged in.

I have set up a global .php file that contains functions used by many pages. One of them starts the session.

function startsession() {
    session_name('login');
    session_set_cookie_params(0, "/", ".raptilic.us");
    session_start();
}

When I access a page on the subdomain that does not call this function or any other session function, the session stays alive. But as soon as I call it from any subdomain, the session is destroyed. Why? Do you know a fix?

The weird thing about it is not just that the session is inaccessible from the subdomain. The session is destroyed.


EDIT : It was a problem with some encryption thing. I solved the issue by putting

php_flag "suhosin.session.cryptdocroot" 0

into the .htaccess file.

尝试这个

ini_set('session.cookie_domain', '.raptilic.us' );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM