PHP Session Management

Source: Internet
Author: User
Tags session id php session

Session use

Before using the session in each page, you must use the Session_Start ()

You can use the $_session global array in each session, and the page must call Session_Start ()

The user's session on the site is unique, even if the page is called Session_Start ()

<? PHP Session_Start (); Echo session_id ()." <br> "; $_session ["added"]+=5; Echo $_session ["added"];? >
Session function
  • Session_abort-discard session array changes and finish session
  • Session_cache_expire-returns the expiration time of the current cache
  • session_cache_limiter-read/Set cache limiter
  • Aliases for Session_commit-session_write_close
  • Session_decode-Decoding session data
  • session_destroy-Destroy all data in a session
  • session_encode-encode the current session data as a string
  • session_get_cookie_params-Get Session cookie Parameters
  • session_id-Get/Set current session ID
  • session_is_registered-Check if the variable is already registered in the session
  • session_module_name-get/Set Session module name
  • session_name-read/Set session name
  • session_regenerate_id-updating an existing session ID with the newly generated session ID
  • session_register_shutdown-Closing a session
  • Session_register-register one or more global variables with the current session
  • Session_reset-re-initialize session array with original values
  • session_save_path-read/Set save path for current session
  • session_set_cookie_params-Setting Session cookie Parameters
  • session_set_save_handler-setting user-defined session store functions
  • Session_start-starting a new session or reusing existing sessions
  • Session_status-returns the current session status
  • Session_unregister-unregister a global variable from the current session
  • Session_unset-free All Session Variables
  • Session_write_close-write session data and end session

Cookie usage

<?PHPSession_Start();if(isset($_post["Submit"])){    Setcookie($_post["Name"],$_post["Value"]);}Echo<<<END<form action= "/info.php" method= "post" target= "_blank" >Cookie Name<input type= ' text ' name= ' name ' value= ' name ' ></input><br>Cookie Value<input type= ' text ' name= ' value ' value= ' 5 ' ></input><br>Submit<input type= ' submit ' name= ' submit ' value= ' Submit ' ></input><br> </form>END;foreach($_cookie  as $name=$value){    Echo"$name:$value<br> ";}?>

PHP Session Management

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.