This example describes the use of the session () method in thinkphp. Share to everyone for your reference, specific as follows:
The system provides the session management and operation of the perfect support, all operations can be completed through a built-in session function.
Usage
Session (Name,name,value= ')
Parameters
Name (required): If an incoming array indicates session initialization, if passing in null indicates emptying the current session, a string represents the session assignment, fetch, or operation.
Value (optional): The session value to set, if passing in NULL indicates a session deletion, the default is an empty string
Session Initialization settings
If the name parameter of the session method is passed in an array, the session initialization setting is represented, for example:
Session (Array (' name ' => ' session_id ', ' expire ' =>3600));
The system starts the session automatically after initialization, and you can set Session_auto_start to False if you do not want the system to start the session automatically
For example:
' Session_auto_start ' =>false
Turn off the public files that can be project after automatic startup or start the session in the Controller by manually calling Session_Start or session (' [Start] ').
Session Assignment
Session (' name ', ' value '); Set session
Session Take value
$value = Session (' name ');
Session deletion
Session (' name ', null); Delete Name
To remove all sessions, you can use:
session (NULL); Empty the current session
Session Judgment
To determine if a session value has been set, you can use the
Used to determine if the session value named name is already set
Session Management
The session method supports some simple session management operations, using the following:
Session (' [Operation name] ');
Session (' [Pause] '); Pause Session Write Session
(' [start] ');/start session session
(' [Destroy] ');/destroy Session session (' [
Regenerate ]'); Regenerate session ID
PHP has its own function session_unset. the effect is to clear (release) All session variables, and if you need to clear a certain conversation variable, you should use the
unset ($_session[' var ']);
More interested readers of thinkphp related content can view the website topic: "thinkphp Introductory Course", "thinkphp template Operation Skill Summary", "thinkphp Common Method Summary", "The CodeIgniter Introductory Course", "CI ( CodeIgniter) Framework Advanced tutorials, introductory tutorials for the Zend framework Framework, Smarty Templates Primer tutorial, and PHP template technology summary.
I hope this article will help you with the PHP program design based on thinkphp framework.