• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • session_unregister()

    (PHP 4, PHP 5 < 5.4.0)

    从当前会话中注销全局变量

    说明

    session_unregister(string $name): bool

    session_unregister()unregisters the global variable named$namefrom the current session.

    Warning

    本函数已自 PHP 5.3.0 起废弃并将自PHP 5.4.0 起移除

    参数

    $name

    The variable name.

    返回值

    成功时返回TRUE,或者在失败时返回FALSE

    注释

    Note:

    If$_SESSIONis used,useunset()to unregister a session variable. Do notunset()$_SESSIONitself as this will disable the special function of the$_SESSIONsuperglobal.

    Caution

    This function does not unset the corresponding global variable for$name, it only prevents the variable from being saved as part of the session. You must callunset()to remove the corresponding global variable.

    Caution

    If you are using$_SESSION(or$HTTP_SESSION_VARS), do not usesession_register(),session_is_registered()andsession_unregister().

    If globals is on, you'll have to unset the $_SESSION[varname] as well as the $varname.
    Like:
    unset($_SESSION[varname]);
    unset($varname);
    To unregister some session you can use:
    <?php
    // delete session
    $_SESSION['NAME'] = array();
    // start session
    session_start();
    // put info in session
    $_SESSION['NAME']['userid'] = 5;
    $_SESSION['NAME']['name'] "John Doe";
    ?>
    
    as a side note you must have session_start() set inorder to actually unregister the session varibles.

    上篇:session_status()

    下篇:session_unset()