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