Configuration and application of PHP Session

<?php
header('Content-Type: text/html; charset=utf-8');

// start a new session or reuse an existing session
session_start();

//Configure Seeeion
$_SESSION['data'] = array('user'=>'chaoyi','website'=>'onestopweb.iteye.com');

//Use Session
print_r($_SESSION['data']);
echo $_SESSION['data']['user'];

// Determine if a Session exists
echo isset($_SESSION['data']) ? 'exists' : 'does not exist';

//Destroy the specified variable
unset($_SESSION['data']);
//Release all $_SESSION variables currently created in memory, but do not delete the session file and do not release the corresponding sessionid
session_unset();
//Delete the session file corresponding to the current user and release the sessionid, the contents of the $_SESSION variable in the memory are still retained
session_destroy();

echo isset($_SESSION['data']) ? 'exists' : 'does not exist';

 

Effect picture:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326690754&siteId=291194637