Variable Sessions in PHP

Source: Internet
Author: User
Tags php session
This article mainly introduces the variable Sessions in PHP, the interested friend's reference, hope to be helpful to everybody.

Before you store user information in a PHP session, you must first start the session.

notes: The session_start () function must precede the

<?php session_start ();?>


Storing and retrieving session variables

The correct way to store and retrieve session variables is to use the PHP$_session variable:

<?phpsession_start ();//store session data$_session[' views ']=1;? >


Destroy session

If you want to delete some session data, you can use the unset () or Session_destroy () function.

The unset () function is used to release the specified session variable:

<?phpsession_start (); if (Isset ($_session[' views ")) unset ($_session[' views ']);? >

The session is completely destroyed by calling the Session_destroy () function:

<?phpsession_destroy ();? >

notes: Session_destroy () resets the session and you will lose all stored session data.

e-mail to prevent injection


    • Filter_sanitize_email filter removes illegal characters from a string in an e-mail message

    • Filter_validate_email Filter Verify the value of the e-mail address

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.