Contoh Pengguna an Session :
1. Memulai session
PHP (start.php)
<?php session_start(); ?>
<html>
<body>
</body>
</html>
2. Menyimpan session
PHP (storing.php)
<?php
session_start();
// store session data
$_SESSION['views']=1;
?>
<html>
<body>
<?php
//retrieve session data
echo "Pageviews=". $_SESSION['views'];
?>
</body>
</html>
3. Melihat session
PHP (view.php)
session_start();
if(isset($_SESSION['views']))
$_SESSION['views']=$_SESSION['views']+1;
else
$_SESSION['views']=1;
echo "Views=". $_SESSION['views'];
?>
4. Menghapus session
PHP (destroy.php)
session_destroy();
?>