Definition: String Session_name ([string $name]) Description:
- Configured in PHP.ini as: Session. Name = Phpsessid
- When the request begins, the session name is reset and stored to the session. name configuration item.
- So if you want to change the php.ini configuration file without changing it, the session_name must be in session_start () or
- Session_register() before setting session_name.
Code Demo:
- [Start session first, then set Session_name]
- <?php
- /**
- * In- Depth understanding of PHP session control
- * User:gutops
- */
- Start a new session
- Session_Start ();
- Set session_name
- Session_name (' phpsessid_new ');
- echo session_name (); // output is phpsessid_new
so sesssion_name not changed, view browser Cookies name for phpsessid (php.ini in the default settings of the Span class= "Hljs-selector-tag" >session.name)
- [Set Session_name again to start session (correct modification mode)]
- <?php
- /**
- * In- Depth understanding of PHP session control
- * User:gutops
- */
- Session_name (' phpsessid_new ');
- Session_Start ();
- echo session_name (); // output is phpsessid_new
查看浏览器cookies,可以看到name变为PHPSESSID_NEW
How PHP session control is set correctly session_name