RE: I cannot read cookie because of ASP.NET Forms Authentication c
- From: "Şenol Akbulak" <senolakbulak@xxxxxxxxxxxxxxxx>
- Date: Fri, 8 Apr 2005 05:51:02 -0700
Hi Kevin,
Thank you about your answer.
My problem is a bit different. I don't trying to use JavaScript to get form
authentication cookies. I try write and read other things to cookie. For
example size of left frame. And I will able size the frame to last width.
I use this JS code:
///******************************************
function GetCookie(Name)
{
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0)
{
offset = document.cookie.indexOf(search)
// if cookie exists
if (offset != -1)
{
offset += search.length
// set index of beginning of value
end = document.cookie.indexOf(";", offset);
// set index of end of cookie value
if (end == -1) end = document.cookie.length;
returnvalue = unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}
function SetCookie (name, value)
{
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (2 < argc) ? argv[2] : null;
var path = (3 < argc) ? argv[3] : null;
var domain = (4 < argc) ? argv[4] : null;
var secure = (5 < argc) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
///******************************************
// And I use this code to read-write sample:
var expdate = new Date();
expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
SetCookie("SenolTestCookie", "cookie test", expdate , "/", "TEST.TEST",
false);
alert(GetCookie("SenolTestCookie"));
alert(document.cookie);
The 2 alert shows me empty on my application. I tried this code on another
web site which is not asp.net (only HTML) it runs successfully.
.
- Follow-Ups:
- RE: I cannot read cookie because of ASP.NET Forms Authentication c
- From: Kevin Yu [MSFT]
- RE: I cannot read cookie because of ASP.NET Forms Authentication c
- References:
- I cannot read cookie because of ASP.NET Forms Authentication cooki
- From: Şenol Akbulak
- RE: I cannot read cookie because of ASP.NET Forms Authentication cooki
- From: Kevin Yu [MSFT]
- I cannot read cookie because of ASP.NET Forms Authentication cooki
- Prev by Date: Migration to jscript.net
- Next by Date: Re: Always Download Image
- Previous by thread: RE: I cannot read cookie because of ASP.NET Forms Authentication cooki
- Next by thread: RE: I cannot read cookie because of ASP.NET Forms Authentication c
- Index(es):