PHP framework-some PHP blog framework adds a static random character to each cookie name, which is why?

Source: Internet
Author: User
Tags cookie names php framework set cookie
For example, these cookie names:
5xhk8d3fgc_user_info
5xhk8d3fgc_comment_author
5xhk8d3fgc_comment_email

What is this for?

Reply content:

For example, these cookie names:
5xhk8d3fgc_user_info
5xhk8d3fgc_comment_author
5xhk8d3fgc_comment_email

What is this for?

You imagine a scenario like this:

You buy a virtual hosting VPS and then deploy a set of blogging programs, and suddenly your girlfriend says you want one, and you deploy a set.
However, you only have a domain name, smart you think of the sub-domain name to distinguish, ok! So soon you have finished the need.

But you found that after the landing of the girlfriend, but the status of the landing under their own domain is actually lost, think what is wrong
So, over and over the check, finally found in the HTTP capture tool under the "own blog under the time of the visit, incredibly pass is the girlfriend over the cookie information." They use the same cookie name, they are cookie.domain still.xxx.com

In fact, the role of cookie prefix is this, and why a lot of background need to set cookie.domain, also this reason. A random prefix can prevent this from happening.

This is actually called a cookie prefix, a cookie prefix, which can be customized.

In fact, before the phper have a lot of bad habits, the main problem without thinking too much.

I don't quite understand cookies.
Let's say the prefix of the session.
On the same server, if you run multiple sites and the Session directory is the same
For example, to define a login in a Web project Is_login = True
Another web is not logged in but may also be retrieved for landing
But with the prefix,
Web1 's Web1_is_login
It won't affect WEB2 's web2_is_login.

A cookie prefix, just like a database table prefix.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.