本文整理匯總了PHP中session::clr方法的典型用法代碼示例。如果您正苦於以下問題:PHP session::clr方法的具體用法?PHP session::clr怎麽用?PHP session::clr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類session
的用法示例。
在下文中一共展示了session::clr方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: clr
static function clr($key)
{
$a = func_get_args();
if (is_array($key)) {
foreach ($key as $k) {
session::clr($k);
}
} elseif (count($a) > 1) {
foreach ($a as $k) {
session::clr($k);
}
} else {
if (isset($_SESSION[$key])) {
unset($_SESSION[$key]);
}
}
}
示例2: suid
/**
* @brief Suid to another user.
*
* The aim of this function is to allow the user to become another user,
* for testing or administrative purposes. It is similar to the sudo and
* su commands in the *nix world.
*
* A user can only suid ONCE, and is only allowed to switch back to the
* previous (original) user by passing NULL as the user record.
*
* @todo Thorougly test
* @param UserRecord $user The user to suid to or null to revert
* @return boolean True on success
*/
static function suid(UserRecord $user = null)
{
$suid = (array) session::get(User::KEY_USER_SUID, null);
if (arr::hasKey($suid, 'issuid') && $user == null) {
// Can unsuid
$uid = $suid['uid'];
session::set(User::KEY_USER_AUTH, $uid);
session::clr(User::KEY_USER_SUID);
// user::set
return true;
} elseif ($user) {
// Can suid
session::set(User::KEY_USER_SUID, array('issuid' => true, 'uid' => user::getActiveUser()->userid, 'suid' => $user->userid));
session::set(User::KEY_USER_AUTH, $user->userid);
return true;
} else {
throw new SecurityException("Invalid suid attempt");
}
}
示例3: initialize
static function initialize()
{
self::$cookies = $_COOKIE;
if (class_exists('session')) {
// Grab the cookie jar and set cookies as needed
self::$jar = (array) session::get('__cookiejar');
// Add the cookies from the jar to the cookies collection so
// we can access them.
foreach (self::$jar as $cookie) {
self::$cookies[$cookie[0]] = $cookie[1];
}
if (!headers_sent()) {
foreach (self::$jar as $cookie) {
call_user_func_array('setcookie', $cookie);
session::clr('__cookiejar');
}
// Then empty the jar
self::$jar = array();
session::clr('__cookiejar');
} else {
throw new BaseException("Cookie jar for delayed cookies loaded but output already started");
}
}
}
示例4: delete
/**
* @brief Delete the current viewstate.
*
* The data will remain in place in the object, so save() can be called
* again to create a new state.
*/
function delete()
{
if ($this->stateid != null) {
session::clr('viewstate_' . $this->stateid);
$this->stateid = null;
} else {
throw new BaseException("Can't delete a non-saved viewstate");
}
}