Session_name ()

Source: Internet
Author: User

Access current session Name

Session_Start() is the beginning of the session mechanism, it has a certain probability to turn on garbage collection, because the session is stored in the file, PHP itself garbage collection is invalid, the session is to delete the file, the probability is based on the configuration of PHP.ini decision. The session will determine if there is a current$_cookie[Session_name()];Session_name() returns the stored session_id cookie key value, which can be used from PHP.INI found:1Session. Name = Phpsessid//Default ValueSession.use_cookies: The default value is "1",On behalf of SessionID use cookies to pass, and vice versa is to pass with Query_string. Session. Name: This is the name of the variable stored by SessionID, either a cookie or a query_string to pass, and the default value is "Phpsessid"Session. Cookie_lifetime: This represents the time that SessionID is stored in the client cookie, the default value is "0", on behalf of the browser closed, SessionID is void, because of this reason, so the session can not be used permanently. Session. Gc_maxlifetime:this is the session data on the server storage time, if more than this time, then the session data is automatically deleted. Session_name()Session_name() to access the current session name. Grammar:string Session_name(string[name]); This function can get or reconfigure the name of the current Session. If no parameter name is given, the name of the session is simply obtained, plus the parameter indicates that the session name is set to the parameter name. If this is the case when it is established Seesion_register ("Test"), then you can use Seesion_name ("test") to find this.session_id() This function is used to number the session as if the PHP array supports character and digital identifiers. 1<?PHP2 3/*set the session name to Nowamagic*/4$str= "Nowamagic";5Session_name($str);6 7Echo Session_name();8 9?>Session_name() andsession_id() The difference we first run the program to see the output:1<?PHP2Session_Start();3Echo Session_name().‘ = '.session_id();4?>Operation Result:1Phpsessid=4d8d3ep8cakmvto6hvut3mphf4 can now be made clear:Session_name() Default to "Phpsessid"andsession_id() is an HTTP request, the server gets the$_post[' Phpsessid '] or$_get[' Phpsessid '] or$_cookie[' Phpsessid '] If you areSession_Start() was called before theSession_name(' SID '); Under normal circumstances (when the client supports cookies), the client is sent a set-cookie:sid= (session_idvalue); A summary sentence: The default value is PHPSESSID, you can modify it with Session_name (). 

Session_name ()

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.