how to display the set cookie to another html page on submit


im practicing on creating a html using jquery cookies. i already know how to set, get, and delete cookies. one thing i don't know is how to display the set cookies on the next page. i have this html ccodes:

<FORM id = 'login' meth0d = 'post' action = 'Coutput.html' > <input id = 'name' type = "text" value = ''> <input id="btnSet" type="submit" value="Go"/> <input id="btndelete" type="button" value="delete cookie"/> </form>

and i have this javascript code:

$('form#login :submit').addClass('inputSubmitBtn').click(function(){ if($('#name').val() == "" ){ $("#name").focus(); alert('please input name'); return false; } else{ $.cookie("cookie_name", null); $.cookie('cookie_name', $('#name').val()); alert('new cookie name' +$('#name').val())); $('#name').append($.cookie('cookie_name')); }; });



why is it that everytime i used $.cookie('cookie_name', $('#name').val(), { expires: null, path: '/', domain: 'cegi1.html', secure: true });, my cookie os always set to null, though i set another one, it always returns null?

</li> <li>

how can i display my newly set cookie in Coutput.html? (ex. name = luke, output in Coutput.html must be "welcome luke")

</li> </ol>

thanks for reading. please help..


It seems that <input id="btnSet" type="submit" value="Go"/> is submitting form to the other page before evaluating $('form#login :submit').click(function(). And also you have got error on alert('new cookie name' +$('#name').val()));. This should work.

<script src="jquery.js"></script> <script src="jquery.cookie.js"></script> <script> $(function () { $("#btnSet").click(function(){ if($('#name').val() == "" ){ $("#name").focus(); alert('please input name'); return false; } else{ $.cookie("cookie_name", null); $.cookie('cookie_name', $('#name').val()); alert('new cookie name' +$('#name').val()); $('#name').append($.cookie('cookie_name')); }; window.location = $(this).parent('form').attr("action"); }); }) </script> <form id = 'login' meth0d = 'post' action = 'Coutput.html' > <input id ="name" type = "text" value=""> <input id="btnSet" type="button" value="Go"/> <input id="btndelete" type="button" value="delete cookie"/> </form>

On my Coutput.html i have

<script src="jquery.js"></script> <script src="jquery.cookie.js"></script> <script> alert($.cookie("cookie_name") ); </script>

If you want to delete the cookie on window close, then use window.unload event and on jquery perhap <a href="http://api.jquery.com/unload/" rel="nofollow">this</a>. And you can delete cookie by resetting it to null.


  • Classic ASP.NET Delete event is not invoked in dynamically generated datagrid control delete link
  • Close Bootstrap Modal On form Submit
  • Deleting checked ListView items
  • How to load more than one div at a time
  • Primefaces ManyCheckbox inside ui:repeat calls setter method only for last loop
  • Passing “get” parameters doesn't work, parameter not visible in the link
  • Switch to popup in python using selenium
  • Eclipse MTJ doesn't see Java ME SDK 3.0 devices
  • Selenium to click on a javascript button corresponding to a text
  • Angularjs pass function from Controller to Directive (or call controller function from directive) -
  • Remove changes from one element when event occurs on another element?
  • Button click event not firing in jQuery
  • Problem while Building a Setup Project for a windows Service?
  • Detect when Facebook like button is clicked
  • Keep this build forever option - Jenkins
  • chrome.tabs.executeScript only fires when the Developer Console is open
  • JSON response opens as a file, but I can't access it with JavaScript
  • dc-js disable selecting slices on click for pie chart
  • Meteor: Do Something On Email Verification Confirmation
  • How to clear text inside text field when radio button is select
  • Android fill_parent issue
  • Java Scanner input dilemma. Automatically inputs without allowing user to type
  • Why ng-show works with ng-repeat but ng-if doesn't? [duplicate]
  • req.body is undefined - nodejs
  • what is the difference between the asp.net mvc application and asp.net web application
  • jquery mobile loadPage not working
  • Web-crawler for facebook in python
  • Properly structure and highlight a GtkPopoverMenu using PyGObject
  • Data Validation Drop Down Box Arrow Disappearing
  • Matrix multiplication with MKL
  • trying to dynamically update Highchart column chart but series undefined
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • How do you join a server to an Active Directory (domain)?
  • How do I configure my settings file to work with unit tests?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Binding checkboxes to object values in AngularJs
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?
  • java string with new operator and a literal