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

What are sessions?

By: Jose Valle

If there is a repeated query in the PHP lists, it is the one related to the use of sessions. The use of sessions is a widely spread method in any application of a certain entity. Basically, a session is the sequence of pages that a user visits in a website, from the moment they log on to the site until they logs out.

The term session in PHP applies to this browsing sequence; to this end we will create a unique identifier that will be assigned to every one of these browsing sessions. This session identifier is commonly known as session.

The process in any programming language could be like this:

Is there a session?
If there is one, retake it
If not, create a new one
Create a unique identifier

And so that we do not interrupt the user browsing, we shall link this session to all URLs and form actions. We can also create a cookie that includes the session identifier, but it is important to remember that the enabling or disabling of cookies depends on the user and it is important not to rely on what the user may or may not have allowed.

All that has been said so far is pure theory and applies to any programming language: C, Perl, etc. Those of us who program in PHP4 have the good luck that all session management is done by PHP itself.

Therefore, every further explanation will apply only to PHP4. If you are still developing PHP3, you will have to create your own session management libraries or use one of the already existing ones, such as PHPLIB. - Introduzca su e-mail y conozca las novedades. No hacemos Spam.
Valid HTML 4.01!
Última modificación:11 de Mayo de 2009. Spain - España.
© 1998-2004 por Joaquin Gracia. Todos los derechos reservados.