PHP Sessions

 PHP Sessions


Sessions allow you to store data on the server that can be accessed across multiple pages. PHP provides built-in functions to start and manage sessions.

Example:


php


// start a session

session_start();


// store data in a session

$_SESSION["name"] = "John";


// retrieve data from a session

if (isset($_SESSION["name"])) {

    echo "Hello " . $_SESSION["name"];

}


// destroy a session

session_destroy();

No comments:

Post a Comment

The Importance of Cybersecurity in the Digital Age

 The Importance of Cybersecurity in the Digital Age Introduction: In today's digital age, where technology is deeply intertwined with ev...