开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜