<?PHP
/*
Cookies:
A cookie is a text-only string that takes a place in the memory of user’s browser.
The main difference between cookies and sessions is that cookies are stored in the user's browser, and sessions are not.
Session:
When you are working with an application, you open it, do some changes and then you close it. This is much like a Session.
A PHP session solves this problem by allowing you to store user information on the server for later use (i.e. username, shopping items, etc). However, session information is temporary and will be deleted after the user has left the website.
when a session is started up, a file is written to the temporary directory on the web server to contain the information for you.
*/
session_start();
if(isset($_SESSION['views']))
$_SESSION['views']=$_SESSION['views']+1;
else
$_SESSION['views']=1;
echo "Views=". $_SESSION['views'];
?>
/*
Cookies:
A cookie is a text-only string that takes a place in the memory of user’s browser.
The main difference between cookies and sessions is that cookies are stored in the user's browser, and sessions are not.
Session:
When you are working with an application, you open it, do some changes and then you close it. This is much like a Session.
A PHP session solves this problem by allowing you to store user information on the server for later use (i.e. username, shopping items, etc). However, session information is temporary and will be deleted after the user has left the website.
when a session is started up, a file is written to the temporary directory on the web server to contain the information for you.
*/
session_start();
if(isset($_SESSION['views']))
$_SESSION['views']=$_SESSION['views']+1;
else
$_SESSION['views']=1;
echo "Views=". $_SESSION['views'];
?>
No comments:
Post a Comment