image


Valora:  1/5
Inicio » PHP » PHP Tutorial » Sessions




Common error

Por: Jose Valle

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 4

PHP 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...





WebEstilo.com - Introduzca su e-mail y conozca las novedades. No hacemos Spam.
Google
  Web WebEstilo.com   
 
Valid HTML 4.01!
Última modificación:25 de Diciembre de 2004. Spain - España.
© 1998-2004 por Joaquin Gracia. Todos los derechos reservados.