Do you want to know about Session with practical in PHP?


Do you want to know about Session with practical in PHP?


Session -: It is used to differentiate particular users on a website.

  • All the Session has a unique ID.
  • When we use Session then it is compulsory to start the Session once a page.
  • It Is basically used for login and logout facility.
  • It used to store temporary data.
  • If once the Session is set then we can take this value everywhere in a project but we use a Session that is compulsory to start the Session.


Session Functions in PHP

    

    Start Session Function -: session_start(); 

   

    Destroy Session -: Means to destroy session with the program.

  1.  When Session is timeout, the user closes the browser. 
  2.  Manually -:

There are two functions to destroy the sessions manually.

  1. session_destroy();
  2.  unset($_SESSION['session_variable_name']);

    Assign a value in a Session

session_start();
$_SESSION['user_name'] = 'Master-tech786';


Take the Session value

session_start();
$u_name = $_SESSION['user_name'];

NOTE -: We can take the value in a Session when value is set in a Session.


Super Globals Variable in PHP?
What is PHP?
What is a Programming Language?



No comments