开发者

PHP session cookie seems to gone when URL does not have WWW in front of it

开发者 https://www.devze.com 2023-04-07 01:55 出处:网络
I put this on my index file: session_se开发者_开发问答t_cookie_params(31536000); session_start();

I put this on my index file:

session_se开发者_开发问答t_cookie_params(31536000);
session_start(); 

It keeps users logged in even when the browser is closed and re-opened.

However, it only works when a WWW in front of my URL. Is there a way to make it work without the WWW in front of the URL?


As per the docs, use this:

session_set_cookie_params( 31536000, '/', '.example.com' );

This will allow the session cookie to be valid for every path (second argument) and every subdomain of example.com (third argument). Replace .example.com with your own of course.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号