Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
helo friends

I m newbie in PHP . I m not able to know what exactly the use of
session is. How can one keep the track of users using Session..


Re: Session

desh wrote:
Quoted text here. Click to load it

this one requires the poster to acually read the docs - as there are  
many fine examples of the proper use of the SESSION variables. - search for session.

Re: Session

noone wrote:
Quoted text here. Click to load it

It also requires a little more knowledge to understand than a newbie  
might have.  The doc is good reference material - but lousy for learning.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Re: Session

thanks Jerry For your help

Re: Session

desh wrote:
Quoted text here. Click to load it

Hello, Desh,

A session is basically a way to remember data between requests.

When a user requests a page, he gets that html.  However, once the page  
has been sent from the server to the user, the server forgets about it.  
  That request is done.  The next request coming in starts "fresh" -  
nothing from the previous page is available.  The closest you can come  
is hidden fields in a form (which is also very insecure).

The session is a way to save information between requests.  The data is  
stored on the server, and a cookie containing the session's unique id is  
sent to the user's browser.  Now when the user requests the next page,  
the cookie is sent back to the server with the request.  The server can  
then retrieve the session information and make it available to the page.

Hope this helps a little.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Re: Session

Quoted text here. Click to load it

The comparison is not 100% valid, but I usually compare a session to a  
shopping cart or a wardrobe.

When you enter a site, you get some space assigned to you. But usually  
without the site knowing who you are. The site does not need to know who  
you are exactly, the site just needs to distinguish the users.
This could be done like in a theater wardrobe: you get a token (a  
ticket) that you have to hand back to access the space that is assigned  
to you and holds your coat, bag or umbrella. While in the theater, you  
can have access any time by just handing over the ticket. You might even  
leave the theater for a few minutes and be able to access "your" private  
The comparison with a shopping cart comes from the fact that it is  
usually the site's stuff you put in your private space. Like IDs of  
items you ordered, your UserID if you are known to the site, etc.

The main difference to the above analogies is that you do not remain  
with your cart. Well, in the theater, you do not stay at the wardrobe  
counter either. You come in and deposit your cloak, during the coffee  
break you decide to get your handkerchief out of your pocket, and you  
recollect your coat after the show. The only times that you are at  
"your" assigned space is when you get or hand over the wardrobe ticket.

It is like that when you visit a website that remembers the state  
between pages. Most often, this is done by giving you a cookie (the  
wardrobe ticket) that serves no other purpose than to bind some server  
space to a visitor. Your browser hands over the cookie when you visit  
the site, so your state can be retrieved by the server. But if you wait  
to long, this (session) cookie will be expired and the space is given  
free for other users.
The session itself is just data storage: a file or a part of a database.

Best regards

Site Timeline