Class CookieHelper
Provides the cookie management methods.
[Obsolete("Will be removed in a later version. Superseded by Kentico.Web.Mvc.ICookieAccessor for working with cookies.")]
public class CookieHelper : AbstractHelper<CookieHelper>
- Inheritance
-
objectCookieHelper
- Inherited Members
- Extension Methods
Constructors
CookieHelper()
public CookieHelper()
Properties
AllowCookies
If true, the cookies are allowed to be used.
public static bool AllowCookies { get; }
Property Value
- bool
Methods
ConvertCookieLevelToIntegerValue(string, int)
Gets the cookie level from a string value
public static int ConvertCookieLevelToIntegerValue(string value, int defaultValue)
Parameters
valuestringLevel value, number or string representation
defaultValueintDefault value
Returns
- int
GetCookieLevelInternal(string)
Gets the cookie level for the given cookie
protected virtual int GetCookieLevelInternal(string cookieName)
Parameters
cookieNamestringCookie name
Returns
- int
GetExistingCookie(string)
Returns the existing cookie.
public static IHttpCookie GetExistingCookie(string cookieName)
Parameters
cookieNamestringCookie name
Returns
- IHttpCookie
GetValue(string)
Returns the given cookie value.
public static string GetValue(string name)
Parameters
namestringCookie name to retrieve
Returns
- string
GetValue(string, bool)
Returns the given cookie value.
public static string GetValue(string name, bool allowSensitiveData)
Parameters
namestringCookie name to retrieve
allowSensitiveDataboolAllows retrieving data from sensitive authentication cookies
Returns
- string
GetValueInternal(string, bool)
Returns the given cookie value.
protected virtual string GetValueInternal(string name, bool allowSensitiveData)
Parameters
namestringCookie name to retrieve
allowSensitiveDataboolAllows retrieving data from sensitive authentication cookies.
Returns
- string
IsCookieAllowed(string)
Returns true if the cookie is allowed based on current cookie level
public static bool IsCookieAllowed(string name)
Parameters
namestringCookie name
Returns
- bool
IsCookieAllowedInternal(string)
Returns true if the cookie is allowed based on current cookie level
protected virtual bool IsCookieAllowedInternal(string name)
Parameters
namestringCookie name
Returns
- bool
RegisterCookie(string, int, bool)
Registers the given cookie within the system.
public static void RegisterCookie(string name, int level, bool isSensitive = false)
Parameters
namestringCookie name
levelintCookie level
isSensitiveboolCookie sensitivity
Remove(string)
Removes the cookie from the client side.
public static void Remove(string name)
Parameters
namestringCookie name to remove
RemoveAllCookies(int)
Removes all the user cookies above given level
public static void RemoveAllCookies(int aboveLevel)
Parameters
aboveLevelintLevel above which the cookies should be removed
RemoveAllCookiesInternal(int)
Removes all the user cookies
protected virtual void RemoveAllCookiesInternal(int aboveLevel)
Parameters
aboveLevelintLevel above which the cookies should be removed
RemoveInternal(string)
Removes the cookie from the client side.
protected virtual void RemoveInternal(string name)
Parameters
namestringCookie name to remove
SetValue(string, string, DateTime, string, bool?, string, SameSiteMode, bool)
Sets the cookie.
public static void SetValue(string name, string value, DateTime expires, string path = null, bool? httpOnly = null, string domain = null, SameSiteMode sameSiteMode = SameSiteMode.Lax, bool secure = false)
Parameters
namestringCookie name
valuestringCookie value
expiresDateTimeExpiration time
pathstringCookie virtual path
httpOnlybool?Defines httpOnly flag.
domainstringDomain to associate the cookie with.
sameSiteModeSameSiteModeValue of the same site attribute.
secureboolIndicates whether the cookie should contain the secure attribute.
SetValue(string, string, string, DateTime)
Sets the cookie.
public static void SetValue(string name, string value, string path, DateTime expires)
Parameters
namestringCookie name
valuestringCookie value
pathstringCookie virtual path
expiresDateTimeExpiration time
SetValue(string, string, string, DateTime, bool?)
Sets the cookie.
public static void SetValue(string name, string value, string path, DateTime expires, bool? httpOnly)
Parameters
namestringCookie name
valuestringCookie value
pathstringCookie virtual path
expiresDateTimeExpiration time
httpOnlybool?Defines httpOnly flag.
SetValue(string, string, string, DateTime, bool?, string)
Sets the cookie.
public static void SetValue(string name, string value, string path, DateTime expires, bool? httpOnly, string domain)
Parameters
namestringCookie name
valuestringCookie value
pathstringCookie virtual path
expiresDateTimeExpiration time
httpOnlybool?Defines httpOnly flag.
domainstringDomain to associate the cookie with.
SetValueInternal(string, string, ref string, DateTime, bool?, string, SameSiteMode, bool)
Sets the cookie.
protected virtual void SetValueInternal(string name, string value, ref string path, DateTime expires, bool? httpOnly, string domain, SameSiteMode sameSite, bool secure)
Parameters
namestringCookie name
valuestringCookie value
pathstringCookie virtual path
expiresDateTimeExpiration time
httpOnlybool?Defines httpOnly flag.
domainstringDomain to associate the cookie with.
sameSiteSameSiteModeSame site mode of the cookie.
secureboolIndicates whether secure attribute should be set for the cookie.