PHP - funny behaviour of cookie variables and session variables

后端 未结 3 1295
-上瘾入骨i
-上瘾入骨i 2021-01-26 17:10

I wrote a little PHP script below to demonstrate my question. Run the code below like this: http://localhost/test.php?test=10, then run http://localhost/test.php?test=11, then

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-26 17:30

    1. Technically you didn't start a session (session_start()) and you're using undefined constant test, however PHP is "intelligent" enough to figure out you mean a string "test".
    2. What's exactly the question?

      Maybe because I cant a cookie and immediately read the same cookie?

      Yes, that's true. You've just proved it.

提交回复
热议问题