Category Archives: session

Delete/Destroy session PHP

You can delete / Destroy session using the PHP function unset()

Example

<?php
session_start();
if(isset($_SESSION[‘phpcodez_views’]))
unset($_SESSION[‘phpcodez_views’]);
?>

Also its possible to completely delete the data using the function session_destroy ()

Example
<?php
session_destroy();
?>

Share

session php

Session variables are used to store values that are required across multiple web pages .

A website can not remember anything about the users those who have already visited the site since the HTTP request does not have state . But at time , it is necessary to remember some details(eg should understand if a user is logged in or not ) . In such case we can use session that enable the website to store the information for later use .

Share