2using System.Globalization;
3using System.Runtime.InteropServices;
5public static class HttpCookie
12 [DllImport(
"__Internal")]
13 private static extern string getHttpCookies();
19 [DllImport(
"__Internal")]
20 private static extern string getHttpCookie(
string name);
30 [DllImport(
"__Internal")]
31 private static extern void setHttpCookie(
string name,
string value,
string expires,
string path,
string domain,
string secure);
39 public static string GetCookie(
string name)
41#if UNITY_EDITOR || UNITY_STANDALONE
44 return getHttpCookie(name);
52 public static void RemoveCookie(
string name)
54#if UNITY_EDITOR || UNITY_STANDALONE
56 setHttpCookie(name,
string.Empty,
"0",
string.Empty,
string.Empty,
string.Empty);
60 public static void RemoveRootCookie(
string name)
62#if UNITY_EDITOR || UNITY_STANDALONE
64 setHttpCookie(name,
string.Empty,
"0",
"/",
string.Empty,
string.Empty);
73 public static void SetCookie(
string name,
string value)
75#if UNITY_EDITOR || UNITY_STANDALONE
78 SetCookie(name, value,
string.Empty,
string.Empty,
string.Empty,
string.Empty);
90 public static void SetCookie(
string name,
string value, DateTime date)
92 var dateJS = date.ToUniversalTime().ToString(
"ddd, dd'-'MMM'-'yyyy HH':'mm':'ss 'GMT'",
93 CultureInfo.CreateSpecificCulture(
"en-US"));
94 SetCookie(name, value, dateJS,
string.Empty,
string.Empty,
string.Empty);
109 public static void SetCookie(
string name,
string value,
string expires,
string path,
string domain,
string secure)
111#if UNITY_WEBGL && !UNITY_EDITOR
112 setHttpCookie(name, value, expires, path, domain, secure);