5

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

3
  • try sessionStorage.setItem('rmng_time', remaining_seconds); Commented Jul 13, 2016 at 6:35
  • which means the plugin is not loaded. check if jquery is loaded. if jquery is loaded then check jquery.session is loaded Commented Jul 13, 2016 at 6:46
  • i check every thing is fine but TypeError: $.session is undefined is showing Commented Jul 13, 2016 at 8:53

5 Answers 5

5

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"));
Sign up to request clarification or add additional context in comments.

Comments

4

You can use jQuery session. See here in the docs.

$.session.set('some key', value);
console.log($.session.get('mobile_no'));

Comments

0

Try :

$(function() {
    $.session.set("myVar", "value");
});


// To Read
$(function() {
    alert($.session.get("myVar"));
});

Comments

0

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/

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.