c# - how get cookie as method parameter -
i cookie on controller , want pass cookie cheklogin method on login.cs type of cookie on cheklogin
public actionresult test() { login.cheklogin(request.cookies["account"]; } checklogin method
public static bool cheklogin()// type of cookie { }
request.cookies["account"] returns httpcookie, that's type checklogin method take parameter:
public static bool cheklogin(httpcookie cookie) { if (cookie != null) { string cookievalue = cookie.value; } } of course if cookie not present in request, request.cookies["account"] return null, make sure take account in cheklogin method.
also, ensure not reinventing wheels or opening site security risks, make sure have read forms authentication in asp.net.
Comments
Post a Comment