javascript - How to Retrieve Cookie Value using Jquery JS Cookie -


i using jquery cookie plugin called js cookie , happens unable retrieve data or value in cookie. store value of cookie inputted on text box , retrieve in text field when page visited again.

$(document).ready(function() {     var cookie_email = cookies.get('user_email');     $('#email_address').val(cookie_email);      $('#test_button').click(function() {         cookies.set('user_email', email_address, {             expires: 365         });     }); }); 

https://jsfiddle.net/mue1amcm/

your code doesn't work don't assign email_address variable anywhere. should change value use $('#email_address').val().

also note jsfiddle isn't setup correctly; url external cookie script goes github page. need use cdn link instead. try this:

var cookie_email = cookies.get('user_email'); $('#email_address').val(cookie_email);  $('#test_button').click(function() {     cookies.set('user_email', $('#email_address').val(), {         expires: 365     }); }); 

working example


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -