-
Notifications
You must be signed in to change notification settings - Fork 0
/
GDPR.cs
39 lines (36 loc) · 1.18 KB
/
GDPR.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
namespace IRB.RevigoWeb
{
public enum GDPRTypeEnum
{
None,
Basic,
Full
}
public static class GDPR
{
public static GDPRTypeEnum GetGDPRState(HttpContext context)
{
GDPRTypeEnum eValue = GDPRTypeEnum.None;
string? cookieValue = WebUtilities.TypeConverter.ToString(context.Request.Cookies["RevigoCookie"]);
if (!string.IsNullOrEmpty(cookieValue))
{
switch (cookieValue.ToLower())
{
case "full":
eValue = GDPRTypeEnum.Full;
cookieValue = "full";
break;
default:
eValue = GDPRTypeEnum.Basic;
cookieValue = "basic";
break;
}
CookieOptions cookieOptions = new CookieOptions();
cookieOptions.Expires = DateTime.Now.AddDays(30);
cookieOptions.SameSite = SameSiteMode.Lax;
context.Response.Cookies.Append("RevigoCookie", cookieValue, cookieOptions);
}
return eValue;
}
}
}