PHP Session Create logout Initialize registration instance Tutorial

Source: Internet
Author: User
Tags define session session id php session php tutorial

The following examples are mainly about the PHP tutorial session in the actual application of the operation, if there is a session to create logoff initialization registration instance.
1
*/

session_start (); Initializing session
$_session["Name"]= "Mike"; Create new value
$_session["Sex"]= "male"; Create new value
Print_r ($_session); Output pre-logoff content
echo "<br>";
echo "----------------------------";
echo "<br>";
Session_unset (); Log off all
Print_r ($_session); Output content again for comparison
Session_destroy (); End Session

2

$barney = "A big purple dinosaur"; Defining string variables
Session_register ("Barney"); Registering the session as a new global variable
$_session["Zim"]= "a invader from another planet."; Define Session Value
$http _session_vars["SpongeBob"]= "He's got square pants." The definition session method of the old version

3

Session_Start (); Initializing session
$_session[' name ']= "Yoursession"; Register a Session variable
$result =session_module_name (); Returns the current module name
echo $result. "        n "; Output results
Session_destroy (); Logout session

4


Session_Start ();            // Initializes the session
$old _sessionid=session_id ();         //gets the current session ID
SESSION_REGENERATE_ID ()          //replaces the current session ID
$new _ with a new value SESSIONID=SESSION_ID ();         //gets the new session ID
Echo "old session: $old _sessionid<br/> ";       //output old session ID
Echo" new session: $new _sessionid <br/>      //output The new session ID
Print_r ($_session);          //Output Session content

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.