Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly is meant by session in the context of a Web Application

Tags:

session

I did a little bit of Web Programming here and there but I never quite understood what's meant by the word Session.

I've googled a bit here and there, read the Wikipedia article, but could never quite grasp the meaning of it.

So, what's a Session?

like image 700
helpermethod Avatar asked Jun 15 '12 09:06

helpermethod


People also ask

What is a session in web applications?

A session is a group of user interactions with your website that take place within a given time frame. For example a single session can contain multiple page views, events, social interactions, and ecommerce transactions.

What does session mean in application?

A session is a period of time wherein a user interacts with an app. Usually triggered by the opening of an app, a session records the length and frequency of app use to show developers, marketers and product managers how much time users spend within an app.

How do you maintain a session in a web application?

Since HTTP and Web Server both are stateless, the only way to maintain a session is when some unique information about the session (session id) is passed between server and client in every request and response. There are several ways through which we can provide unique identifier in request and response.

What is session ID in web application?

A session ID is a unique number that a Web site's server assigns a specific user for the duration of that user's visit (session). The session ID can be stored as a cookie, form field, or URL (Uniform Resource Locator). Some Web servers generate session IDs by simply incrementing static numbers.


4 Answers

Session is a way of persisting your information across multiple pages and requests. When you visit the login page of any site and you provide your username and password, you won't need to provide them again on subsequent pages.

This is done by attaching a session id, unique to your request, and is sent back and forth as you navigate pages.

Session Id could be stored in cookies (file on your system), in the URL as part of query string or in the database

like image 180
codingbiz Avatar answered Nov 06 '22 18:11

codingbiz


A session is a place for storing data for a particular visitor of your site.

You can store data there that is also available on the next page request from that visitor. If some data is stored 'in the session', it means that the data is stored somewhere (possibly in the database of the server or in files) which the server can then use to construct the web page.

The visitor will receive a temporary cookie which contains a session id, an identifier which is used to associate that visitor with the session data that is stored on the web server.

The session id is sent to the server with each request and the server can lookup the stored session data (which can then be used to construct the web page).

like image 29
Simeon Visser Avatar answered Nov 06 '22 17:11

Simeon Visser


It's the concept of keeping state around over an inherently stateless protocol like HTTP.

If you want to keep track of a logged-in user, for example, and maybe some data associated with that user, you could send that data between the server and the client each time, which of course would be terribly insecure. Or you could keep it in a session store on the server, for example a file or a database, and just exchange an identifier for the storage location between client and server. That's usually done via cookies these days, but could also be a parameter in the URL.

like image 20
Thilo Avatar answered Nov 06 '22 18:11

Thilo


To make it simple:

If you first visit the site, the server gives the client an identifier. With this the server can identify a client across several request from the client to the server. The identifier is deleted after a preset time.

The combination of this identifier and the timeframe the identifier is valid, is called session.

Hope that helps. :-)

like image 44
Christoph Eberhardt Avatar answered Nov 06 '22 17:11

Christoph Eberhardt