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 7034905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:14:30+00:00 2026-05-28T01:14:30+00:00

i am trying to use session but i get error: The name ‘Session’ does

  • 0

i am trying to use session but i get error:

The name ‘Session’ does not exist in the current context

what i am doing wrong i am using n-tier and in this page there is no page load function. Session is having link with page_load?

public bool CheckDate(ArrayList roles, string username, string password, string locat)
{
    SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLCONN"].ToString());
    SqlCommand chkdt = new SqlCommand("AccountRoles_GetDateForID", conn);
    chkdt.CommandType = CommandType.StoredProcedure;
    chkdt.Parameters.Add(new SqlParameter("@userName", SqlDbType.VarChar, 32));
    chkdt.Parameters["@userName"].Value = username;
    chkdt.Parameters.Add(new SqlParameter("@password", SqlDbType.VarChar, 250));
    chkdt.Parameters["@password"].Value = password;
    chkdt.Parameters.Add(new SqlParameter("@location", SqlDbType.VarChar, 50));
    chkdt.Parameters["@location"].Value = locat;
    conn.Open();
    try
    {
        DateTime ddt = new DateTime();
        DateTime tdd = DateTime.Parse(DateTime.Now.ToShortDateString());
        SqlDataReader reader = chkdt.ExecuteReader();
        if (reader.HasRows)
        {
            while (reader.Read())
            {
                if (reader["ExpiryDate"].ToString() == "")
                {
                }
                else
                {
                    ddt = DateTime.Parse(reader["ExpiryDate"].ToString());
                }
            }
        }
        TimeSpan ts = ddt.Subtract(tdd);
        day = ts.Days.ToString();
        Session["days"] = day;
        if (tdd.Equals(ddt))
        {               
            return true;
        }
        else
        {
            return false;
        }
    }
    finally
    {
        conn.Close();
        chkdt.Dispose();
    }
}
  • 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-05-28T01:14:30+00:00Added an answer on May 28, 2026 at 1:14 am

    If your method is not in a class that inherits from Page, the Session property isn’t inherited.

    Use the Current property of the HttpContext class to access the current http context where the Session collection is:

    HttpContext.Current.Session["days"] = day;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to get Hibernate session inside a Hibernate Interceptor? I'm trying to use Hibernate
I'm trying to use getServletContext().getRealPath( / ) , but I keep getting this error:
I'm trying to use LsaLogonUser to create an interactive logon session, but it always
I'm trying to customize the session management filter of Spring Security, but I get
I am trying to use PHP session without using cookies. I have enabled session.use_trans_sid
I am trying to use it for Login page. if (Session[UserID] == null) Server.Transfer(/Account/Login,
Trying to use a guid as a resource id in a rest url but
I am trying to get values out of an indexed array, but when I
I am new to capybara but I am trying to use it to test
I got an error when trying to get the value of Int32.Parse(Request.QueryString[PLCID].ToString()) in the

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.