开发者

session does not work with mod-rewrited urls?

开发者 https://www.devze.com 2023-02-02 10:50 出处:网络
I have this page www.exmaple.com/username which is rewritten url, but the sessions does not work there.

I have this page www.exmaple.com/username which is rewritten url, but the sessions does not work there.

That is, when I echo, it does not show the value, but all the other pages that have not been re-written are wo开发者_如何学JAVArking!

<?php session_start();
echo $_SESSION['user_id'];

?>

Is there something that I'm missing?


Does this rewrite involve a change of domain or subdomain in the URL? Cookies are, by default, accessible only to the same subdomain they were set on... and session identifiers are maintained by cookies.


Sessions are not affected by mod_rewrite, but you need to prepend every page with session_start().


You must call session_start() to read the session or $_SESSION will not be populated.

0

精彩评论

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