PHP session using the _php tutorial

Source: Internet
Author: User
Tags echo date php session
1. Session can save any type of data. Because it is stored on the server (that is, it has been serialized).

2. Session Operation mechanism


Session_Start (); The session has been opened, which is equivalent to reading the session information

$_session[' favcolor '] = ' green ';
$_session[' animal ' = ' cat ';
$_session[' time ' = time ();


Works If session cookie was accepted
Echo '
Page 2 ';


page2.php
echo $_session[' Favcolor ']; Green
echo $_session[' animal ']; Cat
echo Date (' Y m D h:i:s ', $_session[' time ');


Session_Start declares the $_session variable, writes the data in the $_session to the data space, and releases the variable for the operation $_session variable, $_session assignment.


Delete $_session cannot be unset, you can set it to null: $_session = Array ();

Delete the current $_session data file Session_destory () under C:windos/temp under the default system path. The directory can be found in the browser

Remove SessionID by using cookie technology within the browser

Setcookie (' Phpsessid ', Time ()-1);


All three can be used together to completely delete a session


3. There may be inconsistencies in the cycle.


http://www.bkjia.com/PHPjc/477496.html www.bkjia.com true http://www.bkjia.com/PHPjc/477496.html techarticle 1. Session can save any type of data. Because it is stored on the server (that is, it has been serialized). 2. Session running mechanism session_start (); Has opened the session, the equivalent of ...

  • 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.