Server
The server is shared by website a and website B. The URLs for accessing A and B are http: // server/a, respectively,
Http: // server/B. When you access site A and site B from client C at the same time, the same session will be assigned.
Id. If it is a coincidence that the session of Site A and the session of Site B use a variable of the same name, it will produce a big problem.
The cause is in the default settings of PHP. ini:
; The path for which the cookie is valid.
Session. cookie_path =/
; The domain for which the cookie is valid.
Session. cookie_domain =
; Whether to use cookies.
Session. use_cookies = 1
C
When you access a for the first time, the site will allocate a sessionid in the cookie. This cookie will be carried every time C accesses.
Session
ID of the session to be processed. If you use the default settings in PHP. ini, the cookie carried by C is valid in the range of http: // server. When C
This cookie will also be carried when B is accessed, and B will see that there is a session in the cookie
The session is read, and the session is the session assigned to C by site B.
One way to solve this problem is to set your own independent parameters when writing code. For example:
Ini_set ('session. cookie_path ', dirname ($ _ server ['script _ name']);
Ini_set ('session. name', 'mysessionname ');