$_SESSION in PHP

What is $_SESSION in PHP ?

$_SESSION is the PHP global variable to set and retrieve session values in PHP.A session is started with the session_start() function.A session is a way to store information (in variables) to be used across multiple pages.Unlike a cookie, the information is not stored on the users computer.

In PHP we are using $_SESSION for creating and retrieving the variable values,the syntax is same but way of using is different .

 
Syntax : $variable = $_SESSION [‘Session key’];
  

above syntax is use to get the value of session from the key.

 
Syntax :  $_SESSION [‘Session key’]=$variable ;
  

above syntax is use to store the value of session into key.

Scroll to Top