// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; using System.Threading.Tasks; namespace Microsoft.AspNetCore.Http { public interface ISession { /// /// Indicate whether the current session has loaded. /// bool IsAvailable { get; } /// /// A unique identifier for the current session. This is not the same as the session cookie /// since the cookie lifetime may not be the same as the session entry lifetime in the data store. /// string Id { get; } /// /// Enumerates all the keys, if any. /// IEnumerable Keys { get; } /// /// Load the session from the data store. This may throw if the data store is unavailable. /// /// Task LoadAsync(); /// /// Store the session in the data store. This may throw if the data store is unavailable. /// /// Task CommitAsync(); /// /// Retrieve the value of the given key, if present. /// /// /// /// bool TryGetValue(string key, out byte[] value); /// /// Set the given key and value in the current session. This will throw if the session /// was not established prior to sending the response. /// /// /// void Set(string key, byte[] value); /// /// Remove the given key from the session if present. /// /// void Remove(string key); /// /// Remove all entries from the current session, if any. /// The session cookie is not removed. /// void Clear(); } }