Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I need to pass a value from one page to another through javascript, I dont want to pass by query string. because query string is visible to all.

Is there any way to pass value from one page to another page other than by query string

Thank you

Sanju
Posted
Comments
Abhishek Pant 3-Mar-13 4:53am    
use cookies
Sanju TV 3-Mar-13 5:03am    
can i set value for a cookie using javascript..?
Sanju TV 3-Mar-13 5:39am    
thank u, got solved

Use cookies: Javascript Cookies[^]
 
Share this answer
 
Javascript code
C#
function SetCookie(cookieName, cookieValue, nDays) {
    var today = new Date();
    var expire = new Date();
    if (nDays == null || nDays == 0) nDays = 1;
    expire.setTime(today.getTime() + 3600000 * 24 * nDays);
    document.cookie = cookieName + "=" + escape(cookieValue)
                 + ";expires=" + expire.toGMTString();
}


ASP.Net code to get cookie
C#
lblTitle.Text = Request.Cookies["key"].Value;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900