1<?php
2 // Start the session
3 session_start();
4?>
5<!DOCTYPE html>
6<html>
7 <body>
8 <?php
9 // Set session variables
10 $_SESSION["color"]= "blue";
11 $_SESSION["animal"]= "dog";
12 echo "The session variable are set up.";
13 ?>
14 </body>
15</html>
1<?php
2 // Start the session
3 session_start();
4
5 // Set session variables
6 $_SESSION["color"]= "blue";
7 $_SESSION["animal"]= "dog";
8 echo "The session variable are set up.";
9?>
1if ( !session_id() ) {
2 session_start( [
3 'read_and_close' => true,
4 ] );
5}
6
1
2<?php
3// This sends a persistent cookie that lasts a day.
4session_start([
5 'cookie_lifetime' => 86400,
6]);
7?>
8
9