how can I create session in jquery?
58,927
Solution 1
You need to reffer this tutorial:
http://phprocks.letsnurture.com/create-session-with-jquery/
Add required files and refer code -
jquery-1.9.1.js and jquery.session.js
ex.
To set session:
$(function() {
$.session.set("myVar", "Hello World!");
});
To get session:
alert($.session.get("myVar"));
Solution 2
You can use jQuery session. See here in the docs.
$.session.set('some key', value);
console.log($.session.get('mobile_no'));
Author by
Aasiya Mairaj
I am working as a php developer since last two years
Updated on July 09, 2022Comments
-
Aasiya Mairaj almost 2 years
Here is my code. jquery.session.js file is also loaded I could not get where is the problem. Can you Please tell me the solution.
$.session.set('rmng_time', remaining_seconds); alert("j session "+$.session.get('rmng_time'));
this code gives an error in console TypeError: $.session is undefined
-
Amar Singh almost 8 yearstry
sessionStorage.setItem('rmng_time', remaining_seconds);
-
Cerlin almost 8 yearswhich means the plugin is not loaded. check if jquery is loaded. if jquery is loaded then check jquery.session is loaded
-
Aasiya Mairaj almost 8 yearsi check every thing is fine but TypeError: $.session is undefined is showing
-