Search Tutorials


Handle Session using jQuery | JavaInUse



Handle Session using jquery



In 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-

Adding Session-
Usage- $.session.set('some key', 'a value');
Adding new value to session-
Example- $.session.set('username', 'test');
 

Fetching Session-
 
Usage-$.session.get('some key');
returns "a value"
Adding new value to session-
Example- $.session.get('username');

Removing Session-
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();

See Also

Spring Boot Interview Questions Apache Camel Interview Questions Drools Interview Questions Java 8 Interview Questions Enterprise Service Bus- ESB Interview Questions. JBoss Fuse Interview Questions Angular 2 Interview Questions