How to register a variable in PHP session ?

devquora
devquora

Posted On: Apr 15, 2024

 

    1 Answer Written

  •  devquora
    Answered by devquora

    In PHP 5.3 or below, you can register a variable session_register() function. It is deprecated now and you can set directly a value in $_SESSION Global. Example:

    <? php 
       // Starting session
        session_start();
       // Use of session_register() is deprecated
        $username = "PhpScots";
        session_register("username");
       // Use of $_SESSION is preferred
        $_SESSION["username"] = "PhpScots";
    ?>
    

Related Questions

Please Login or Register to leave a response.

Related Questions

PHP Interview Questions

What is T_PAAMAYIM_NEKUDOTAYIM in PHP?

T_PAAMAYIM_NEKUDOTAYIM is scope resolution operator used as :: (double colon) .Basically, it used to call static methods/variables of a Class...

PHP Interview Questions

What is the difference between == and === operator in PHP ?

In PHP == is equal operator and returns TRUE if $a is equal to $b after type juggling and === is Identical operator and return TRUE if $a is equal to $b, and they are of the same data type...