Hi, I am here to make you understand some concepts about session. But wait. Before that I want to tell you a story of mine. After that I will be back to the topic Session. I like to eat too much specially fast foods like burger, pizzas, fried chickens etc on the other hand I am a bit lazy also. Don't want to go to the shop . So I have kept a boy named "Sam" whose only duty is to go to my nearby shop and order them food and bring the food to me. As this is my nearby shop and I have been purchasing food from there so many times they want to give me some discount on food. But there is a rule to get this discount. The rule is whoever goes to buy the food (me or Sam) he has to show an id of mine to the order section and also in the cash section. Based on the id the shopkeepers and cashier decides to give discount. But you know what? Sam's capability of memorizing something is very poor. When he goes to order section of the shop he can tell my id but when he goes to the cash section he forgets my id!!! In order to solve this problem what the shopkeepers are doing is at the order section when Sam is telling my Id they are keeping a note and forward it to the cash section. So now no matter whether Sam can memorize my id or not. Shop keepers are keeping the note. :)
Ok enough talking now lets come to the main point. go through the story again and replace me with client browser, request of food with requested data, my id with additional data, Shop with Server, Sam with HTTP, the note of id with session data and delivery of food as Server response :).
Me = client browser.
Request of food = Requested Data
My Id = Additional Data,
Shop = Server,
Sam = HTTP,
The note of my ID = Session Data,
Delivery of Food = Server Response.
Session is like that. When you request your server from browser using HTTP. the HTTP is a state less protocol. The page you are requesting with an additional data , that particular additional data is available to only that page. but when you goes to another page the data is lost. To make that data available also at another page, the server keeps the information of that data as session variable. Using that session variable you can have the data available at another page too just like my id is available both at order section and cash section.
Thanks for reading :). More technical terms about session will be discussed later.
Ok enough talking now lets come to the main point. go through the story again and replace me with client browser, request of food with requested data, my id with additional data, Shop with Server, Sam with HTTP, the note of id with session data and delivery of food as Server response :).
Me = client browser.
Request of food = Requested Data
My Id = Additional Data,
Shop = Server,
Sam = HTTP,
The note of my ID = Session Data,
Delivery of Food = Server Response.
Session is like that. When you request your server from browser using HTTP. the HTTP is a state less protocol. The page you are requesting with an additional data , that particular additional data is available to only that page. but when you goes to another page the data is lost. To make that data available also at another page, the server keeps the information of that data as session variable. Using that session variable you can have the data available at another page too just like my id is available both at order section and cash section.
Thanks for reading :). More technical terms about session will be discussed later.
Learning with real life example!!! Really nice concept, thanks for the post.
ReplyDeleteThanks for reading. :)
Deletenice example
ReplyDelete