Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to access cookies value from Javascript.

Status
Not open for further replies.

AnNguyen

Programmer
Jul 18, 2002
33
0
0
US
Is there way for ASP.NET to read cookies value that were set with Javascript in PHP page?
Thank in advance.

//Setting cookies with javascript in a PHP page. It is
// written from a third party that i can not changed.
<script LANGUAGE="JavaScript" >

function setCookie(cookieName,cookieValue) {
document.cookie = cookieName +"=" + cookieValue;
}
function Report(Item) {
setCookie("Rep","1"); // it can be 1, 2,3....
document.Form1.action= "mySite/dir/Report.aspx";
document.Form1.submit();
}

</SCRIPT>

//in the ASP.net Page load (C#) it always write
//"Rep is null".
//The asp.net page can not access the cookies????.

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if ( Request.Cookies["Rep"] == null)
Response.Write("Rep is null");
else
Response.Write("Rep: " + Request.Cookies["Rep"].Value.Tostring();
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top