Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Problem with Keep me Logged in.

Problem with Keep me Logged in.

Scheduled Pinned Locked Moved ASP.NET
csharphelpasp-net
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    varshavmane
    wrote on last edited by
    #1

    Hello All, I am working in ASP.NET 2008 (C#). I have to keep user logged in till he logout's. I did the following but its not working in all Pages. Specially on that page where I have used Web Parts. function KeepmeLoggedIn() { if ('<% =keepmeloggedin %>' != '') { var sessionTime = (10 * 60000) - 30000; window.setInterval('window.location.reload()',sessionTime ); } } Above Function is call in the body tag of Master Page, something like this: In code Behind of Master Page: public string keepmeloggedin = ""; protected void Page_Load(object sender, EventArgs e) { if (Request.Cookies["Collabs"] != null) { HttpCookie cookie = Request.Cookies.Get("Collabs"); keepmeloggedin = cookie.Values["keepmeloggedin"].ToString(); KeepMeLogedIn.Text = keepmeloggedin; //KeepMeLogedIn is TextBox KeepMeLogedIn.Visible = false; } } On Login User Control I have this: If chkKeepLoggedIn.Checked Then Dim cookie As New HttpCookie("Collabs") Response.Cookies.Add(cookie) cookie("keepmeloggedin") = "true" Response.Cookies("Collabs").Expires = DateTime.Now.AddDays(15) Else Dim cookie As New HttpCookie("Collabs") Response.Cookies.Add(cookie) cookie("keepmeloggedin") = "" Response.Cookies("Collabs").Expires = DateTime.Now.AddDays(15) End If Above code works fine sometimes and sometime it doesnt. Please help me... Thanks in advance...

    R 1 Reply Last reply
    0
    • V varshavmane

      Hello All, I am working in ASP.NET 2008 (C#). I have to keep user logged in till he logout's. I did the following but its not working in all Pages. Specially on that page where I have used Web Parts. function KeepmeLoggedIn() { if ('<% =keepmeloggedin %>' != '') { var sessionTime = (10 * 60000) - 30000; window.setInterval('window.location.reload()',sessionTime ); } } Above Function is call in the body tag of Master Page, something like this: In code Behind of Master Page: public string keepmeloggedin = ""; protected void Page_Load(object sender, EventArgs e) { if (Request.Cookies["Collabs"] != null) { HttpCookie cookie = Request.Cookies.Get("Collabs"); keepmeloggedin = cookie.Values["keepmeloggedin"].ToString(); KeepMeLogedIn.Text = keepmeloggedin; //KeepMeLogedIn is TextBox KeepMeLogedIn.Visible = false; } } On Login User Control I have this: If chkKeepLoggedIn.Checked Then Dim cookie As New HttpCookie("Collabs") Response.Cookies.Add(cookie) cookie("keepmeloggedin") = "true" Response.Cookies("Collabs").Expires = DateTime.Now.AddDays(15) Else Dim cookie As New HttpCookie("Collabs") Response.Cookies.Add(cookie) cookie("keepmeloggedin") = "" Response.Cookies("Collabs").Expires = DateTime.Now.AddDays(15) End If Above code works fine sometimes and sometime it doesnt. Please help me... Thanks in advance...

      R Offline
      R Offline
      Ravi Sant
      wrote on last edited by
      #2

      Please edit your question using proper

      pre code

      tags

      ♫ 99 little bugs in the code, 99 bugs in the code We fix a bug, compile it again 101 little bugs in the code ♫

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups