PHP session Add, Delete, modify, view operation, phpsession_php tutorial

Source: Internet
Author: User

PHP session Add, Delete, modify, view operation, Phpsession


The difference between a session and a cookie is that the cookie file is stored on the client, and the session is stored on the server, and in contrast, the session is more advantageous for a certain amount of security.

Because the session in the server side of the general situation is the management of the server, but the cookie is in the client's save, anyone can see, if not specified, the password is also clear text preservation, security is obvious.

And the session is relatively more powerful, you can save the array, and even the object, in a way, can reduce the development cost.

Here is the code used for the session:

Increase of Session data:
Copy the Code code as follows:
<?php
Header ("content-type:text/html; Charset=utf-8; "); /utf-8 display, not related to session
Session_Start ();//Start session data Save
$_session[' name ']= "xuning"; *//add SESSION data.
?>

Deletion of session data.
Copy the Code code as follows:
<?php
Header ("content-type:text/html; Charset=utf-8; "); /utf-8 display, not related to session
Session_Start ();//Start session data
unset ($_session[' name ']= "xuning"); *//Delete SESSION data.
Session_destory ();//Delete all session
?>

The session is modified to increase the session data.
The session data is viewed, i.e. the session data is removed.

Copy the Code code as follows:
<?php
Session_Start ();
Print_r ($_session);//Get SESSION
echo $_session[' name '];
?>

Either the cookie or session ends at the end of a session, which closes the browser and ends the session.

http://www.bkjia.com/PHPjc/970994.html www.bkjia.com true http://www.bkjia.com/PHPjc/970994.html techarticle PHP session to add, delete, modify, view operation, phpsession session and the difference between the cookie is the first, the cookie file is saved on the client, and the session is saved in the server ...

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