Allow php sessions to carry over to subdomains

前端 未结 10 1365
清歌不尽
清歌不尽 2020-11-22 01:10

I use php sessions (not cookies, except for session id cookie) for all user data, and when a user goes to their profile user.mydomain.com they are immediately \"logged out\"

10条回答
  •  轮回少年
    2020-11-22 02:08

    Here are 4 options.

    Place this in your php.ini:

    session.cookie_domain = ".example.com"
    

    Or in your .htaccess:

    php_value session.cookie_domain .example.com
    

    Or as the first thing in your script:

    ini_set('session.cookie_domain', '.example.com' );
    

    Or in your php-fpm pool configuration for your site:

    php_value[session.cookie_domain] = .example.com
    

提交回复
热议问题