Disclaimer: This website requires JavaScript to function properly. Some features may not work as expected. Please enable JavaScript in your browser settings for the best experience.

Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsGitHubDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

ICookieManager

Describes ICookieManager in Optimizely Configured Commerce.

protected virtual CustomerOrder GetCustomerOrderForNotLoggedUser()
{
    var customerOrderId = this.CookieManager.Get(this.CartCookieName);
    return customerOrderId.IsBlank()
        ? null
        : this.UnitOfWork.GetRepository<CustomerOrder>().Get(customerOrderId);
}

The example below is an excerpt from the CartOrderProviderByUser. For non-authenticated users, the cart is stored in a cookie. The example attempts to retrieve the customerOrderId from the cookie in order to retrieve the cart for the user.

Example

  • name – The name of the cookie to remove.

Parameters

void Remove(string name)

Removes a cookie from the HTTP request. Also, adds an expired cookie of the same name to the HTTP response.

Remove(string)

  • name – The name of the cookie to add.
  • value – The value to store inside the cookie.
  • expires – The date and time that the cookie should expire.

Parameters

void Add(string name, string value, DateTimeOffset? expires = null)

Adds a cookie to the HTTP response and sets the expiration date and time.

Add(string, string, DateTimeOffset)

If the cookie is found, this returns the value of the cookie.

Returns

  • name – The name of the cookie for which to search.

Parameters

string Get(string name)

Returns the value of a cookie in the HTTP request.

Get(string)

Methods

This is a wrapper class that lets you more manipulate HTTP cookies on the server.

Description