本文整理汇总了PHP中session_unset函数的典型用法代码示例。如果您正苦于以下问题:PHP session_unset函数的具体用法?PHP session_unset怎么用?PHP session_unset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了session_unset函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loggedOutProtect
public function loggedOutProtect()
{
if ($this->loggedIn() === false) {
header('Location: ' . BASE_URL . 'login');
exit;
}
// source: http://stackoverflow.com/a/1270960/2790481
// last request was more than 1 day ago
if (isset($_SESSION['LAST_ACTIVITY']) && time() - $_SESSION['LAST_ACTIVITY'] > 86400) {
session_unset();
// unset $_SESSION variable for the run-time
session_destroy();
// destroy session data in storage
header('Location: ' . BASE_URL . 'login');
exit;
}
$_SESSION['LAST_ACTIVITY'] = time();
// update last activity time stamp
if (!isset($_SESSION['CREATED'])) {
$_SESSION['CREATED'] = time();
} else {
if (time() - $_SESSION['CREATED'] > 3600) {
// session started more than 1 hour ago
$id = $_SESSION['id'];
// better security - avoid fixation attack.
session_regenerate_id(true);
// change session ID for the current session and invalidate old session ID
$_SESSION['CREATED'] = time();
// update creation time
$_SESSION['id'] = $id;
$_SESSION['LAST_ACTIVITY'] = time();
// update last activity time stamp
}
}
}
示例2: actionLoginout
public function actionLoginout()
{
session_start();
session_destroy();
session_unset();
$this->redirect("/");
}
示例3: logout
public function logout()
{
// remove and destroy session variables
session_unset();
session_destroy();
header('Location: ' . $this->base_url());
}
示例4: logoutAction
public function logoutAction()
{
session_unset();
session_destroy();
$ret["statusCode"] = CODE_SUCCESS;
echo UtilsModel::getUrlJson($ret);
}
示例5: createSession
function createSession($login, $nombre, $apellido, $email)
{
//Creo un token para mas seguridad
$token = md5(rand() . $login);
//Creo un Jugador
$j = new jugador();
$j->setLogin($login);
$j->setToken($token);
//Actualizo token en la DB
$j->updateToken($token);
//Inicio sesion y borro lo que haya guardado dentro de ella
session_start();
session_unset();
//Variables del usuario
$_SESSION['login'] = $login;
$_SESSION['nombre'] = $nombre;
$_SESSION['apellido'] = $apellido;
$_SESSION['email'] = $email;
//Variables para seguridad de sesion
$_SESSION['registered'] = 1;
$_SESSION['userAgent'] = $_SERVER['HTTP_USER_AGENT'];
$_SESSION['IPaddress'] = $_SERVER['REMOTE_ADDR'];
$_SESSION['LastActivity'] = $_SERVER['REQUEST_TIME'];
$_SESSION['token'] = $token;
}
示例6: clear
public function clear()
{
session_unset();
@session_regenerate_id(true);
@session_start();
$this->data = $_SESSION = array();
}
示例7: check_login
function check_login($link, $user, $pass)
{
if (!ctype_alnum(str_replace(array('@', '.', '-'), '', $user))) {
return false;
}
$pass = escapeshellcmd($pass);
$result = mysqli_query($link, "SELECT password FROM admin WHERE superadmin='1' AND username='{$user}'");
while ($row = mysqli_fetch_array($result, MYSQL_NUM)) {
$row = "'" . $row[0] . "'";
if (strpos(shell_exec("echo {$pass} | doveadm pw -s SHA512-CRYPT -t {$row}"), "verified") !== false) {
return "admin";
}
}
$result = mysqli_query($link, "SELECT password FROM admin WHERE superadmin='0' AND active='1' AND username='{$user}'");
while ($row = mysqli_fetch_array($result, MYSQL_NUM)) {
$row = "'" . $row[0] . "'";
if (strpos(shell_exec("echo {$pass} | doveadm pw -s SHA512-CRYPT -t {$row}"), "verified") !== false) {
return "domainadmin";
}
}
$result = mysqli_query($link, "SELECT password FROM mailbox WHERE active='1' AND username='{$user}'");
while ($row = mysqli_fetch_array($result, MYSQL_NUM)) {
$row = "'" . $row[0] . "'";
if (strpos(shell_exec("echo {$pass} | doveadm pw -s SHA512-CRYPT -t {$row}"), "verified") !== false) {
return "user";
}
}
session_unset();
session_destroy();
session_write_close();
setcookie(session_name(), '', 0, '/');
sleep(1);
return false;
}
示例8: teardown
public function teardown()
{
session_unset();
if (session_id() !== '') {
session_destroy();
}
}
示例9: logout
public function logout()
{
$title = 'Logout';
session_start();
session_unset();
return header('Location: http://localhost/music/public/login');
}
示例10: check_user
function check_user($secret_key, &$db)
{
if (!isset($_SESSION['userid']) || !isset($_SESSION['hash'])) {
header("Location: ../index.php");
exit;
} else {
$check = sha1($_SESSION['userid'] . $_SERVER['REMOTE_ADDR'] . $secret_key);
if ($check != $_SESSION['hash']) {
session_unset();
session_destroy();
header("Location: ../logout.php");
exit;
} else {
$query = $db->execute("select * from `players` where `id`=?", array($_SESSION['userid']));
$userarray = $query->fetchrow();
if ($query->recordcount() == 0) {
session_unset();
session_destroy();
header("Location: ../logout.php");
exit;
}
foreach ($userarray as $key => $value) {
$user->{$key} = $value;
}
return $user;
}
}
}
示例11: setDeconnexion
public function setDeconnexion()
{
// On détruit les variables de notre session
session_unset();
// On détruit notre session
session_destroy();
}
示例12: groundup_new_user_cookie
function groundup_new_user_cookie()
{
// start a new session to track new visits expires after 30 minutes
session_start();
if (isset($_SESSION['last_activity']) && time() - $_SESSION['last_activity'] > 1800) {
// last request was more than 30 minutes ago
session_unset();
// unset $_SESSION variable for the run-time
session_destroy();
// destroy session data in storage
}
$_SESSION['last_activity'] = time();
// update last activity time stamp
if (!isset($_SESSION['new_user_check'])) {
$_SESSION['new_user_check'] = '1';
if (!is_admin() && !is_login() && !is_register()) {
if (!isset($_COOKIE['new_user'])) {
$visit = 0;
} else {
$visit = $_COOKIE['new_user'] + 1;
}
setcookie('new_user', $visit, time() + 3600 * 24 * 100, '/', COOKIE_DOMAIN, false);
}
}
}
示例13: testControllerFlash
function testControllerFlash()
{
session_unset();
$controller = new Controller();
# sets the ceva from the flash to altceva
$test = new TestController();
$this->assertTrue(empty($test->flash));
$test->index();
$this->assertEqual($test->flash["ceva"], "altceva");
# calls the destruct method that puts the flash into the session
unset($test);
# reinit test
$test = new TestController();
$this->assertEqual($test->flash["ceva"], "altceva");
$test->index();
$test->flash["altceva"] = "ceva";
$this->assertEqual($test->flash["ceva"], "altceva");
$this->assertEqual($test->flash["altceva"], "ceva");
# the flash remainds unmodified
unset($test);
# the flash is now destroyed
$test = new TestController();
$this->assertEqual($test->flash["altceva"], "ceva");
session_destroy();
}
示例14: ajaxAction
public function ajaxAction()
{
$this->_helper->viewRenderer->setNoRender(true);
if (!empty($_POST)) {
$method = $_POST['method'];
header('Content-Type: application/json');
switch ($method) {
case 'userLogin':
$data = $this->_WeTransfer_Users->login($_POST['username'], $_POST['password']);
$json = array();
$json['data'] = $data;
if ($data == 'LOGIN_OK') {
$json['status'] = 'OK';
} else {
session_unset();
session_destroy();
$json['status'] = 'ERROR';
switch ($data) {
default:
$json['error'] = $data;
}
}
break;
default:
$json = array();
$json['status'] = 'ERROR';
$json['error'] = 'UNHANDLED_EXCEPTION';
}
exit(json_encode($json));
} else {
header('Location: ' . BASEURL . '');
}
}
示例15: action_index
function action_index()
{
session_start();
session_unset();
session_destroy();
header('Location: home');
}