Zend.com Tutorials for Absolute Beginners
http://www.zend.com/php/beginners/php101-10.php
A Session In The Cookie Jar
By Vikram Vaswani
So close your eyes, take a deep breath, and read on to find out all about
this tutorial's topic: sessions and cookies.
Sessions and cookies thus provide an elegant way to bypass the stateless nature of the HTTP protocol,
and are used on many of today's largest sites to track and maintain information for personal and commercial transactions.
Typically, you use a session to store values that are required over the course of a single visit,
and a cookie to store more persistent data that is used over multiple visits.
The First Session
<?php
// initialize a session
session_start();
// increment a session counter
$_SESSION['counter']++;
// print value
echo "You have viewed this page " . $_SESSION['counter'] . " times";
?>
Now to my ( halojoy ) general question here:
When should I use session, cookie or database?
Or any combination of them?
When do I use one or the other and why?
Is there any general rule we could have or is it random howto do this?
Track our visitors. Right to Privacy.
In Sweden we have law, that websites should have an info
that cookies are used, or a visible link in startpage to info on 'privacy'.
This includes also use of temporary session variables used to store user session.
😕