Return to Snippet

Revision: 73411
at July 8, 2018 05:19 by devquora


Initial Code
<?php 
//starting a session
session_start();
//Creating a session 
$_SESSION['user_info']=['user_id'=>1,'first_name'=>'php','last_name'=>'scots','status'=>'active'];

//checking session
if(isset($_SESSION['user_info'])){
echo "logged In";
}

//un setting remove a value from session
unset($_SESSION['user_info']['first_name']);

// destroying complete session
session_destroy();

?>

Initial URL
https://www.onlineinterviewquestions.com/core-php-interview-questions/

Initial Description
As HTTP is state protocol.To maintain states on server and share data across multiple pages PHP session are used.PHP sessions are simple way to store data for individual users/client against a unique session ID.Session IDs are normally sent to the browser via session cookies and the ID is used to retrieve existing session data,if session id is not present on server PHP creates a new session, and generate a new session ID.

Initial Title
Working with Sessions in PHP

Initial Tags
php

Initial Language
PHP