How do PHP sessions work when cookies are disabled?

后端 未结 3 1483
忘了有多久
忘了有多久 2020-12-14 19:12

I\'ve tried to research this mechanism but only find hints and these are not very consistent. How is the session _id sent to the browser and how is the browser instructed to

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-14 19:47

    PHP will do 2 things:

    • It will rewrite all links to pass an extra GET parameter, usually PHPSESSID but this can be changed by setting session.name in php.ini
    • It will add a hidden input with the same name after all
      opening tags.

    Note that this is a dangerous thing to do, because anyone who you e.g. copy/paste a URL to containing an PHPSESSID parameter will be able to share your login session on the site - the webserver has no easy way of telling that you are different from the person you sent the link to...

提交回复
热议问题