c# - Problem with HttpOnly Cookies -
have problem creating httponly cookies , use following code creat new cookie:
//a.aspx httpcookie ht = new httpcookie("www"); ht.value = "www"; ht.name = "www"; ht.httponly = true; ht.expires = datetime.now.adddays(1); response.appendcookie(ht); response.redirect("b.aspx"); //b.aspx httpcookie cookie = request.cookies["allowed"]; httpcookie htt = request.cookies["www"]; if (cookie != null) { response.write(cookie.httponly); response.write(htt.httponly); } else { cookie = new httpcookie("allowed"); cookie.httponly = true; cookie.value = "ping"; cookie.expires = datetime.now.addminutes(2); response.cookies.add(cookie); response.write(cookie.httponly); response.write(htt.httponly); }
the problem final result : false
, although httponly property set true
.
can explain me way figure out ?
thanx
cookie parameters (expiration date, path, httponly etc) not sent server browser, values. sending them introduce unnecessary bloat. therefore cookies in request.cookies
contain names , values.
if want see if httponly value taking effect, use firecookie or similar inspect cookies. or try accessing them in javascript - that's it's supposed prevent.
Comments
Post a Comment