Is there a way to pass data between pages without using cookies and a server-side language in javascript? every way I found incorporates cookies or a server-side language (PHP session vars).
+3
A:
You can pass it through a query string.
This link will give you the code to get it using JavaScript.
code snippet from the page:
function getQuerystring(key, default_)
{
if (default_==null) default_="";
key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
var qs = regex.exec(window.location.href);
if(qs == null)
return default_;
else
return qs[1];
}
Kevin
2009-11-16 20:49:25
+1
A:
You can always add data to the url query string when you navigate, like:
/site/page2?username=foo&bar=110
Of course you have to recognize that users can manipulate those values so some kind of validation will still be necessary when the new page loads and uses those values.
Mike Clark
2009-11-16 20:49:32