Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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_start();

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

unset($_SESSION['username']);

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

session_destroy();




$username = 'James';

if(isset($_SESSION['username'])){
    echo 'Session is set';
}else{
    echo 'Session not Exist';
}

?>```
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading