Showing posts with label Session. Show all posts
Showing posts with label Session. Show all posts

Wednesday 11 June 2014

Session in PHP


Session in PHP

A Normal HTML website will not pass data from one page to another. In other words all Information is forgotten when new page is loaded. This makes it quite a problem for tasks like a shopping cart which requires data to be remembered from one page to the next.

A PHP session solves this problem by allowing you to store infomation on the server for later use.(i.e. username, shopping cart items etc..) However this session information is temporary and is usually deleted very quickly after the user has left the website.

<?php
session_start();
$_session['view'] = 1;
 ?>

For close session:
<?php
session_write_close();
session_destroy();
?>