March 10, 2021, 10:28 p.m.
A session can be defined as a server side storage of information that is persist throughout the user interaction with the website or web application. We can store data in the browser of client machine to get the preferences of particular user.
A session can be defined as a server side storage of information that is persist throughout the user interaction with the website or web application. We can store data in the browser of client machine to get the preferences of particular user.
When a browser connects to the server it creates a session, which the server keeps track of. The session maintains connection and other information server side. Sessions are the mechanism for keeping track of the "state" between the site and a particular browser. Sessions allow you to store arbitrary data per browser, and have this data available to the site whenever the browser connects. Individual data items associated with the session are then referenced by a "key", which is used both to store and retrieve the data.
Example:
num_visits=request.session.get('num_visits',1)
request.session['num_visits']=num_visits+1