Skip to content

Instantly share code, notes, and snippets.

@trnktms
Created October 31, 2019 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trnktms/9b6bba7563f44db0053a74001abf9e7d to your computer and use it in GitHub Desktop.
Save trnktms/9b6bba7563f44db0053a74001abf9e7d to your computer and use it in GitHub Desktop.
public static class SessionExtensions
{
public static void AddSessionWithStartSession(this IServiceCollection services)
{
services.AddSingleton<ISessionStore, DistributedSessionStoreWithStart>();
services.AddDistributedMemoryCache();
services.AddSession(options =>
{
options.Cookie.IsEssential = true;
});
services.AddSingleton<IStartSession>(s =>
{
var startSession = new StartSession();
// Add here other actions if more funcionality is needed for session start
startSession.AddToStartSession(s.GetRequiredService<IUrlRefererService>().SetSessionStartRefererUrl);
return startSession;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment