码迷,mamicode.com
首页 > 其他好文 > 详细

Helpers\Sessions

时间:2016-07-05 14:07:29      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:

Helpers\Sessions

The session is a static class, this means it can be used in any controller without needing to be instantiated, the class has an init method if session_start() has not been set then it starts it. This call is in place in (Core/Config.php) so it can already be used with no setup required.

The advantages of using a session class is all sessions are prefixed using the constant setup in the root index.php file, this avoid sessions clashing with other applications on the same domain.

Usage

Setting a session, call Session then ::set pass in the session name followed by its value

Session::set(‘username‘, ‘Dave‘);

To retrieve an existing session use the get method:

Session::get(‘username‘);

Pull an existing session key and remove it, use the pull method:

Session::pull(‘username‘);

Use id to return the session id.

Session::id();

Destroy a session key by calling:

Session::destroy(‘mykey‘);

To look inside the sessions array, call the display method:

print_r(Session::display());

Helpers\Sessions

标签:

原文地址:http://www.cnblogs.com/chunguang/p/5643196.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!