Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9037141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:10:32+00:00 2026-06-16T09:10:32+00:00

I have a User table. I’m using Forms authentication and have the following code

  • 0

I have a User table. I’m using Forms authentication and have the following code for logon:

 public JsonResult LogOn(FormCollection form)
 {
        var agent = SiteUserRepository.CheckAgent(form["Email"], form["Password"]);
        if (agent == null)
            return Json(new
            {
                IsSuccess = false,
                Message = "Wrong email or password"
            });
        SiteUserRepository.UpdateLastLogon(agent.Email);

        FormsAuthentication.SetAuthCookie(agent.Email, true);
        ApplicationSession.CurrentUser = agent;

        return Json(new
            {
                IsSuccess = true
            });

 }

The ApplicationSession is my wrapper for Session object.

public static class ApplicationSession
{
    private const string _currentUser = "CurrentUser";
    public static SiteUser CurrentUser
    {
        get
        {
            var user = HttpContext.Current.Session[_currentUser];
            if (user != null)
                return (SiteUser)user;
            return null;
        }
        set
        {
            HttpContext.Current.Session[_currentUser] = value;
        }
    }

}

The session timeout equals 1440 (24 h). I need exactly this value.
For example user login on site. Then I delete this user from DB. And user will be authenticated (if they don’t click Log Off, of course). What is the best approach to solve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T09:10:33+00:00Added an answer on June 16, 2026 at 9:10 am

    You want to use a cookie. Your code needs to check for the cookie and if it doesn’t exist, or the time has expired on it, you create a new one.

    I think this will show you a nice example:

    C# Cookies based on login information

    http://www.beansoftware.com/ASP.NET-Tutorials/Cookies-ASP.NET.aspx

    a remember me checkbox type implementation with an expiration of a day could be done something like this:

    if (chBox.Checked)
    
          {
              HttpCookie myCookie = new HttpCookie("Cookie_Remember"); //new cookie object
    
              Response.Cookies.Remove("Cookie_Remember"); //This will remove previous cookie
              Response.Cookies.Add(Cookie_Remember); //This will create new cookie
    
              Cookie_Remember.Values.Add("UserInfo", txt_username.Text); //Add User Name 
    
            // You can add multiple values
    
              DateTime CookieExpir= DateTime.Now.AddDays(5); //Cookie life
    
              Response.Cookies["Cookie_Remember"].Expires = CookieExpir; //Maximum day of cookie's life       
          }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In SQL Server 2008 I have a user table like the following: Userid Username
I have a User table with foreign key pointing to the Address Table. public
I have a user table in my database that looks like this: public class
I'm using rails 3 with devise. I have a User table with fields: email,
I have a user table with a level column. The level column is numeric
I have a User table that has all of their avatars saved in an
I have a user table 'users' that has fields like: id first_name last_name ...
I have a User table which has a PrivilegeId foreign key points to a
I have a user table like this FIRSTNAME | LASTNAME | ID | --------------------------------
Consider i have a user table and I have three columns mobilePhone , homePhone

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.