title: Asp.Net core "remember me" persistent cookie not works after deploy
body: <p>I've built an MVC Core (Framework) application and I use Identity to login.
  When I click "Remember me" option all is ok on my develop machine, but after deploy on server machine, "remember me" doesn't maintain login after 30 minutes.</p>
  
  <p>I tried to check if cookie expiry date is set and seems to be ok, also on server machine the cookie seems well set.
  You can see my cookies detail in following image:</p>
  
  <p><a href="https://i.stack.imgur.com/Jfw19.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Jfw19.png" alt="enter image description here"></a></p>
  
  <p>Can anyone help me to solve this issue?</p>
  
  <p>Thanks in advance for your reply :)</p>
  
  <p>EDIT:</p>
  
  <p>As required by Orhun, I add below my Startup.cs content:</p>
  
  <pre><code>public partial class Startup
  {
      public SymmetricSecurityKey signingKey;
  
      public Startup(IHostingEnvironment env)
      {
          var builder = new ConfigurationBuilder()
              .SetBasePath(env.ContentRootPath)
              .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
              .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
  
          if (env.IsDevelopment())
          {
              // For more details on using the user secret store see https://go.microsoft.com/fwlink/?LinkID=532709
              builder.AddUserSecrets&lt;Startup&gt;();
          }
  
          builder.AddEnvironmentVariables();
          Configuration = builder.Build();
      }
  
      public IConfigurationRoot Configuration { get; }
  
      // This method gets called by the runtime. Use this method to add services to the container.
      public void ConfigureServices(IServiceCollection services)
      {
  
          ///////////////////////////
          // Custom Services - START
          ///////////////////////////
  
          string conn = CreateConnectionString(Configuration.GetConnectionString("TiesseWebConnection"));
          services.AddScoped&lt;System.Data.Entity.DbContext&gt;((_) =&gt; new TiesseWeb.DAL.TiesseWebEntities(conn));  //Configuration["Data:DefaultConnection:ConnectionString"]));
  
  
          // SESSION section
          services.AddMemoryCache();
          services.AddDistributedMemoryCache();
          services.AddSession();
  
          services.AddSingleton&lt;IConfiguration&gt;(Configuration);   // IConfiguration explicitly
  
          // Add functionality to inject IOptions&lt;T&gt; (important for inject Config object)
          services.AddOptions();
  
  
          // Add our Config object so it can be injected
          services.Configure&lt;Settings&gt;(Configuration.GetSection("Settings"));
          // Add our Config object so it can be injected
          services.AddScoped&lt;Settings&gt;();
  
          services.AddScoped&lt;Tiesse.Web.BL.TiesseWebManager&gt;();
  
          ///////////////////////////
          // Custom Services - END
          ///////////////////////////
  
          // Add framework services.
          services.AddDbContext&lt;ApplicationDbContext&gt;(options =&gt;
              options.UseSqlServer(Configuration.GetConnectionString("TiesseWebConnection")));
  
  
          services.AddIdentity&lt;ApplicationUser, ApplicationRole&gt;(i =&gt;
          {
              i.SecurityStampValidationInterval = TimeSpan.FromDays(14);
              //i.Cookies.ApplicationCookie.ExpireTimeSpan = TimeSpan.FromDays(14);
          })
          //services.AddIdentity&lt;ApplicationUser, ApplicationRole&gt;()//IdentityRole&gt;()
            .AddEntityFrameworkStores&lt;ApplicationDbContext, int&gt;()
            .AddDefaultTokenProviders();
  
          services.AddMvc().AddJsonOptions(jsonOptions =&gt;
          {
              jsonOptions.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
          }); ;
  
          // Add application services.
          services.AddTransient&lt;IEmailSender, AuthMessageSender&gt;();
          services.AddTransient&lt;ISmsSender, AuthMessageSender&gt;();
  
          // Adds Authorizations
          services.AddAuthorization(options =&gt;
          {
              options.AddPolicy("Admin", policy =&gt; policy.RequireClaim("Admin"));
              options.AddPolicy("Admin-Utenti", policy =&gt; policy.RequireClaim("Admin-Utenti"));
              options.AddPolicy("Admin-Filiali", policy =&gt; policy.RequireClaim("Admin-Filiali"));
              options.AddPolicy("Admin-Reparti", policy =&gt; policy.RequireClaim("Admin-Reparti"));
              options.AddPolicy("GoogleDrive", policy =&gt; policy.RequireClaim("GoogleDrive"));
              options.AddPolicy("GoogleDrive-Gestione", policy =&gt; policy.RequireClaim("GoogleDrive-Gestione"));
              options.AddPolicy("GoogleDrive-Gestione-Struttura", policy =&gt; policy.RequireClaim("GoogleDrive-Gestione-Struttura"));
              options.AddPolicy("GoogleDrive-Consultazione", policy =&gt; policy.RequireClaim("GoogleDrive-Consultazione"));
              options.AddPolicy("Reports", policy =&gt; policy.RequireClaim("Reports"));
              options.AddPolicy("Reports-Test", policy =&gt; policy.RequireClaim("Reports-Test"));
          });
      }
  
      // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
      public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
      {
          // Custom settings
          app.UseSession();
  
          //// configures Bearer token Authentication
          //ConfigureAuth(app);
          ///////////////////
  
  
          loggerFactory.AddConsole(Configuration.GetSection("Logging"));
          loggerFactory.AddDebug();
  
          if (env.IsDevelopment())
          {
              app.UseDeveloperExceptionPage();
              app.UseDatabaseErrorPage();
              app.UseBrowserLink();
          }
          else
          {
              app.UseExceptionHandler("/Home/Error");
              //app.UseDeveloperExceptionPage();
              //app.UseDatabaseErrorPage();
              //app.UseBrowserLink();
          }
  
          app.UseStaticFiles();
  
          app.UseIdentity();
  
          app.UseCookieAuthentication(new CookieAuthenticationOptions
          {
              //CookieName = "MyWebCookie",
              //CookieDomain = "http://devweb01:81",      // uncomment when deploy
              CookieHttpOnly = true,
              CookieSecure = CookieSecurePolicy.Always,
              ExpireTimeSpan = TimeSpan.FromDays(30),
              SlidingExpiration = true,
              AutomaticAuthenticate = true,
              AutomaticChallenge = true
              //AuthenticationScheme = "MyeWebCookie"
          });
  
          app.UseGoogleAuthentication(new GoogleOptions()
          {
              // following Goggle Secrets data have been hardcoded because Configuration with Secrets.json works only in development environment
              ClientId = "XXXXXXX....",
              ClientSecret = "XXXXXXX....",
              AutomaticAuthenticate = true
              //SignInScheme = "MyWebCookie"
          });
  
          app.UseMvc(routes =&gt;
          {
              routes.MapRoute(
                  name: "default",
                  template: "{controller=Home}/{action=Index}/{id?}");
          });
      }
  
      #region Methods
  
      public static string CreateConnectionString(string providerConnectionString)
      {
          var entityBuilder = new EntityConnectionStringBuilder();
  
          // use your ADO.NET connection string
          entityBuilder.ProviderConnectionString = providerConnectionString;
  
          entityBuilder.Provider = "System.Data.SqlClient";
  
          // Set the Metadata location.
          entityBuilder.Metadata = @"res://*/TiesseWebDB.csdl|res://*/TiesseWebDB.ssdl|res://*/TiesseWebDB.msl";
  
          return entityBuilder.ConnectionString;
      }
  
      #endregion
  }
  </code></pre>