One of the most common errors when using sessions is to leave blank rows before starting PHP or to send some output to screen. To prove this, create a blank row or anything else before <?php.
If cookies are enabled, you will find this kind or error:
Warning: Cannot send session cookie - headers already sent by (output started at /home/session.php:2) in /home/session.php on line 4PHP is informing that cookies cannot be enabled in the user web browser because the headers have already been sent. Just by the mere existence of a blank row. As a practical rule, do not leave blank spaces neither before the beginning of the script nor after its completion.
You will avoid a lot of trouble.
If after all the abovementioned, you still do not understand what sessions are for, we will have a practical example. Imagine that you are trying to create a shopping cart system...