// Copyright © 2015 The CefSharp Authors. All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. using System; using System.ComponentModel; using System.Diagnostics; using CefSharp.Enums; using CefSharp.Internals; namespace CefSharp { /// /// Class used to Represent a cookie. /// The built in .Net Cookie class isn't used as some of it's properties have /// internal setters /// [DebuggerDisplay("Domain = {Domain}, Path = {Path}, Name = {Name}, Secure = {Secure}, HttpOnly = {HttpOnly}," + "Creation = {Creation}, Expires = {Expires}, LastAccess = {LastAccess}", Name = "Cookie")] public sealed class Cookie { /// /// The cookie name /// public string Name { get; set; } /// /// The cookie value. /// public string Value { get; set; } /// /// If domain is empty a host cookie will be created instead of a domain cookie. Domain cookies are stored with a leading "." /// and are visible to sub-domains whereas host cookies are not. /// public string Domain { get; set; } /// /// Ss non-empty only URLs at or below the path will get the cookie value. /// public string Path { get; set; } /// /// If true the cookie will only be sent for HTTPS requests. /// public bool Secure { get; set; } /// /// Ss true the cookie will only be sent for HTTP requests. /// public bool HttpOnly { get; set; } /// /// Expires or null if no expiry /// public DateTime? Expires { get; set; } /// /// The cookie creation date. This is automatically populated by the system on cookie creation. /// public DateTime Creation { get; private set; } /// /// The cookie last access date. This is automatically populated by the system on access. /// public DateTime LastAccess { get; private set; } /// /// Same site. /// public CookieSameSite SameSite { get; set; } /// /// Priority /// public CookiePriority Priority { get; set; } /// /// Used internally to set . /// can only be set when fecting a Cookie from Chromium /// /// /// Represents a wall clock time in UTC. Values are not guaranteed to be monotonically /// non-decreasing and are subject to large amounts of skew. Time is stored internally /// as microseconds since the Windows epoch (1601). /// /// /// Hidden from intellisense as only meant to be used internally, unfortunately /// VC++ makes it hard to use internal classes from C# /// [EditorBrowsable(EditorBrowsableState.Never)] public void SetCreationDate(long baseTime) { Creation = CefTimeUtils.FromBaseTimeToDateTime(baseTime); } /// /// Used internally to set . /// can only be set when fecting a Cookie from Chromium /// /// /// Represents a wall clock time in UTC. Values are not guaranteed to be monotonically /// non-decreasing and are subject to large amounts of skew. Time is stored internally /// as microseconds since the Windows epoch (1601). /// /// /// Hidden from intellisense as only meant to be used internally, unfortunately /// VC++ makes it hard to use internal classes from C# /// [EditorBrowsable(EditorBrowsableState.Never)] public void SetLastAccessDate(long baseTime) { LastAccess = CefTimeUtils.FromBaseTimeToDateTime(baseTime); } } }