当前位置: 首页>>代码示例>>PHP>>正文


PHP session_unset函数代码示例

本文整理汇总了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
         }
     }
 }
开发者ID:sass-team,项目名称:sass-app,代码行数:35,代码来源:General.class.php

示例2: actionLoginout

 public function actionLoginout()
 {
     session_start();
     session_destroy();
     session_unset();
     $this->redirect("/");
 }
开发者ID:Revege,项目名称:rz,代码行数:7,代码来源:LoginController.php

示例3: logout

 public function logout()
 {
     // remove and destroy session variables
     session_unset();
     session_destroy();
     header('Location: ' . $this->base_url());
 }
开发者ID:ahmedBassell,项目名称:dbproject,代码行数:7,代码来源:student.php

示例4: logoutAction

 public function logoutAction()
 {
     session_unset();
     session_destroy();
     $ret["statusCode"] = CODE_SUCCESS;
     echo UtilsModel::getUrlJson($ret);
 }
开发者ID:sunniecc,项目名称:web_pakpobox,代码行数:7,代码来源:User.php

示例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;
}
开发者ID:brunitosessa,项目名称:armaelequipo,代码行数:25,代码来源:login.php

示例6: clear

 public function clear()
 {
     session_unset();
     @session_regenerate_id(true);
     @session_start();
     $this->data = $_SESSION = array();
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:7,代码来源:internal.php

示例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;
}
开发者ID:efux,项目名称:mailcow,代码行数:34,代码来源:functions.inc.php

示例8: teardown

 public function teardown()
 {
     session_unset();
     if (session_id() !== '') {
         session_destroy();
     }
 }
开发者ID:chrispoupart,项目名称:BicBucStriim,代码行数:7,代码来源:CsrfTokenTest.php

示例9: logout

 public function logout()
 {
     $title = 'Logout';
     session_start();
     session_unset();
     return header('Location: http://localhost/music/public/login');
 }
开发者ID:navi15486,项目名称:MusicMVC,代码行数:7,代码来源:adminController.php

示例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;
        }
    }
}
开发者ID:BGCX067,项目名称:ezrpg-svn-to-git,代码行数:28,代码来源:lib.php

示例11: setDeconnexion

 public function setDeconnexion()
 {
     // On détruit les variables de notre session
     session_unset();
     // On détruit notre session
     session_destroy();
 }
开发者ID:shibiro,项目名称:Melody,代码行数:7,代码来源:User.php

示例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);
         }
     }
 }
开发者ID:abacusadvertising,项目名称:groundup,代码行数:25,代码来源:helpers.php

示例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();
 }
开发者ID:hurrycane,项目名称:framework,代码行数:25,代码来源:controller_tests.php

示例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 . '');
     }
 }
开发者ID:madberry,项目名称:WhiteLabelTransfer,代码行数:33,代码来源:LoginController.php

示例15: action_index

 function action_index()
 {
     session_start();
     session_unset();
     session_destroy();
     header('Location: home');
 }
开发者ID:maksym1up,项目名称:tour_firm,代码行数:7,代码来源:controller_logout.php


注:本文中的session_unset函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。