start a session in php code example
Example 1: end session variable php
<?php
session_destroy();
?>
Example 2: php start a session
session_start();
if(!isset($_SESSION["started"]){
$_SESSION["started"] = true;
$_SESSION["attribute_1"] = $value_1;
...
$_SESSION["attribute_n"] = $value_n;
}
Example 3: set php varibianle session
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<body>
<?php
$_SESSION["color"]= "blue";
$_SESSION["animal"]= "dog";
echo "The session variable are set up.";
?>
</body>
</html>
Example 4: session start php
<?php
session_start([
'cookie_lifetime' => 86400,
]);
?>