thinkphp Development Framework function Detailed: Session method

Source: Internet
Author: User
Keywords Development framework function session method thinkphp
Tags aliyun array delete development development framework different framework function

The session method is used to http://www.aliyun.com/zixun/aggregation/16962.html the >session settings, get, delete, and manage operations.

Session is used for session settings, fetch, delete, and manage Action usage session ($name, $value = ') parameter name (required): If an incoming array represents a session initialization, if passing in null indicates emptying the current session, If it is a string, the session assignment, fetch, or operation is represented.
Value (optional): The session value to set, if passing in NULL represents deleting the session, the default is empty string return value See details (return different values according to the specific usage)

The session function is a multiplication function, in which different parameters can be invoked to perform different function operations, including the following functions.

Session Initialization settings

If the name parameter of the session method passes in an array, the session initialization setting is represented, for example:

Session (Array (' name ' => ' session_id ', ' expire ' =>3600));

The incoming session parameters are supported including:

Parameter name Description ID session_id Value name session_name value path Session_save_path value prefix session localization space prefix expire session.gc_maxlifetime settings Value domain Session.cookie_domain Set value use_cookies session.use_cookies set value Use_trans_sid session.use_trans_sid set Value cache_ Limiter Session_cache_limiter Set Value Cache_expire Session_cache_expire Set Value type session hander types, you can use the hander Drive extension

The session initialization method does not need to be called manually, and will be invoked automatically after the initialization of the app class is done, usually the project only needs to configure the Session_options parameter, the session_options parameter setting is an array, The supported index names are the same as the previous session initialization parameters.
By default, 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 assignment is relatively simple, direct use:

Session (' name ', ' value '); Set session

Equivalent:

$_session[' name ' = ' value ';

Session value

Session value using:

$value = Session (' name ');

Equivalent to use:

$value = $_session[' name '];

Session deletion

Session (' name ', null); Delete Name

Equivalent:

unset ($_session[' name '));

To remove all sessions, you can use:

session (NULL); Empty the current session

Equivalent:

$_session = Array ();

Related Article

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.