Handle Session using jqueryIn this tutorial we understand the session management using jquery. A web session is a sequence of network HTTP request and response transactions associated to the same user. Modern and complex web applications require the retaining of information or status about each user for the duration of multiple requests. Therefore, sessions provide the ability to establish variables – such as access rights and localization settings – which will apply to each and every interaction a user has with the web application for the duration of the session.
If the application is developed using jquery then session management can be done using the Jquery session plugin. This jquery session plugin can be downloaded at jquery session plugin
Include the above jquery session plugin in our index page The following session handling operations can now be performed as follows-
Usage- $.session.set('some key', 'a value'); Adding new value to session- Example- $.session.set('username', 'test');
Usage-$.session.get('some key'); returns "a value" Adding new value to session- Example- $.session.get('username');
Usage- $.session.remove('some key'); Adding new value to session- Example- $.session.set('username');
Clearing all sessions-
Usage- $.session.clear(); Clearing all sessions set in the variable session. Example- $.session.clear();