explain working of session_start() in php

How the session_start() works in php?
When we write session_start() at top of the file, how the things are working in background.If anyone can explain.

>Solution :

Session in PHP is just a variable that stores value in it. the session_start() is used to tell that we are using session variable in this code and that this function is mainly come at first whenever we want to use session and then when we want to remove value from it we could simply use session_destroy() function to remove the value from that variable
Moreover, Session is mostly used when performing login. the username could be store in the variable that is declare as a session variable


$_SESSION['username'] = 'John';


echo $_SESSION['username']; 
echo '/';


$username = 'James';

    echo 'Session is set';
    echo 'Session not Exist';


Leave a Reply