Skip to content

Instantly share code, notes, and snippets.

@codehaks
Created October 7, 2018 08:22
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 codehaks/91e8955ed9c67a2048cebcfe4e19c3db to your computer and use it in GitHub Desktop.
Save codehaks/91e8955ed9c67a2048cebcfe4e19c3db to your computer and use it in GitHub Desktop.
Setting Identity Cookie TimeSpan
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddDbContext<AppDbContext>(options =>
options.UseSqlite("Data Source=app.db"));
services.AddDefaultIdentity<IdentityUser>()
.AddEntityFrameworkStores<AppDbContext>();
services.Configure<CookieAuthenticationOptions>(options =>
{
options.ExpireTimeSpan = TimeSpan.FromDays(1);
options.Cookie.Expiration = TimeSpan.FromDays(2);
});
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseStaticFiles();
app.UseAuthentication();
app.UseMvcWithDefaultRoute();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment