1.

Which one of the following statements should you use to set the session username to Nachi?(a) $SESSION[‘username’] = “Nachi”;(b) $_SESSION[‘username’] = “Nachi”;(c) session_start(“nachi”);(d) $SESSION_START[“username”] = “Nachi”;I got this question by my school principal while I was bunking the class.I want to ask this question from Session Handling-2 topic in chapter File and Session Handling in PHP of PHP

Answer»

Right answer is (b) $_SESSION[‘USERNAME’] = “Nachi”;

For EXPLANATION: You NEED to refer the session variable ‘username’ in the CONTEXT of the $_SESSION SUPERGLOBAL.



Discussion

No Comment Found

Related InterviewSolutions