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
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'));
Share Improve this question asked Jul 13, 2016 at 6:32 Aasiya MairajAasiya Mairaj 1851 gold badge3 silver badges17 bronze badges 3 |this code gives an error in console TypeError: $.session is undefined
5 Answers
Reset to default 5You 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"));
You can use jQuery session. See here in the docs.
$.session.set('some key', value);
console.log($.session.get('mobile_no'));
Try :
$(function() {
$.session.set("myVar", "value");
});
// To Read
$(function() {
alert($.session.get("myVar"));
});
First you have to include the jquery session library files to run the $.session. so, follow this link http://code.ciphertrick.com/2015/01/20/session-handling-using-jquery/
You can store the some specific data to the active session like
sessionStorage.setItem("loginData",JSON.stringify(logObj));
And you can access the the stored data from the session like :-
sessionStorage.loginData
sessionStorage.setItem('rmng_time', remaining_seconds);
– Amar Singh Commented Jul 13, 2016 at 6:35