PHP Sessions


  1. What is the return type of session_set_save_handler() function?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Returns TRUE on success or FALSE on failure.


  1. Which function is used to erase all session variables stored in the current session?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    This will not completely remove the session from the storage mechanism. If you want to completely destroy the session, you need to use the function session_destroy().



  1. What will the function session_id() return is no parameter is passed?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Previous Session Identification Number


  1. Which one of the following statements should you use to set the session username to Manjesh?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    You need to refer the session variable ‘username’ in the context of the $_SESSION superglobal.



  1. What will be the output of the following PHP code? Say your previous session username was Manjesh.
    unset($_SESSION['username']);
    printf("Username now set to: %s", $_SESSION['username']);











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    To delete the session variable ‘username’ we use the unset() function.