Session Operations in PHP

Start PHP Session

Before you can store user information in a PHP session, you must first start a session

<?php 
   session_start(); 
?>

Store Session Variables

<?php 
    $_SESSION['UserName']='gqink';
?>

Retrieve Session Variables

<?php 
    echo $_SESSION['UserName'];
?>

Delete Session

<?php 
    unset($_SESSION['UserName']);
?>

Completely Destroy the Session

<?php 
    session_destroy();
?>

session_destroy() will reset the session, and you will lose all stored session data

Article repost policy

Request authorization before reposting and retain the authorization code, original URL, and go/affiliate links.

Original URL: https://www.geekcorelab.cn/en-US/post/session-operations-in-php