PHP creating new session with each reload

后端 未结 5 699
无人及你
无人及你 2021-01-18 06:02

For my website, session management mostly works ok. Sessions are created, saved and used later without problems.

But when the code is using session_start(), it alway

5条回答
  •  春和景丽
    2021-01-18 06:55

    Cookies are only returned to the vhost / path where they were set from.

    Since your path is '/', that implies that the pages are not being requested via $domain . "." . $tld;

    e.g. user requests page via www.example.com

    cookie is set for example.com

    user access subsequent page from www.example.com - the cookie is not in scope.

    From RFC 2965

    x.y.com domain-matches .Y.com but not Y.com.

    Actually, if you read on, the spec does say that the user agent should prefix the host with a dot if none is supplied however you getting into the realm where browser behavuiour varies.

    If you simply return the cookie with a vhost matching the request it will work as expected.

提交回复
热议问题