public SetCookie ( string name, string value, System.DateTime expiresAt, string path, bool secure = false, bool httpOnly = false ) : void | ||
name | string | |
value | string | |
expiresAt | System.DateTime | |
path | string | |
secure | bool | |
httpOnly | bool | |
Résultat | void |
public void SetCookie(string name, string value, DateTime expiresAt, string path, bool secure = false, bool httpOnly = false)
{
path = path ?? "/";
var cookie = $"{name}={value};expires={expiresAt.ToString("R")};path={path}";
if (secure)
cookie += ";Secure";
if (httpOnly)
cookie += ";HttpOnly";
this.Headers[HttpHeaders.SetCookie] = cookie;
}
HttpResult::SetCookie ( string name, string value, System.TimeSpan expiresIn, string path ) : void |