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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:41:12+00:00 2026-05-26T00:41:12+00:00

I have a problem with using session variable in the page_load . I have

  • 0

I have a problem with using session variable in the page_load. I have a page (members.aspx) which is a members area.

If the user isn’t logged in, it will display a form asking them to login. The form submits their details, checks if ok then sets session variables if OK. It then reloads the page.

So if the user has authenticated correctly, it sets Session["memberLoggedIn"] = true.
My page_load function then looks like this

protected void Page_Load(object sender, EventArgs e)
{
    if (Convert.ToBoolean(Session["memberLoggedIn"]) == true) {
        Response.Write("OK");
    }
}

There is more code, but essentially, the “OK” should be written. However, it doesn’t appear. Even though the session IS set. If I go to the page directly it will then show. It’s just for the reloading of the members page from the initial login which stops it.

any ideas?!

======================
the code to set the session is

if (logindetails.Count > 0) {
    System.Data.DataRow details = logindetails[0];
    Session["memberLoggedIn"] = true;
}

I then just check if (Convert.ToBoolean(Session["memberLoggedIn"]) == true) on all my pages. To be honest it doesn’t seem that reliable and I Think sometimes I need to understand the order in which pages are loaded as when I destroy the session on the log out page, some parts still show the logged in features! (but that’s another story….)

  • 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-26T00:41:13+00:00Added an answer on May 26, 2026 at 12:41 am

    try this

    protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                var user = HttpContext.Current.User;
                if(user.Identity.IsAuthenticated)
                {
                     Session["memberLoggedIn"] = true;
                     Print();
                }
            }
        }
    
        public void Print()
        {
                if (Convert.ToBoolean(Session["memberLoggedIn"]) == true)
                {
                    Response.Write("ok");
                }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a problem with using session variables. I have two controllers named
I have a service (WCF) with which my ASP.NET page will communicate. The WCF
I have problem while using jquery maskedinput with asp.net textbox. I have a check
I have a problem using the Java search function in Eclipse on a particular
I have a problem using Linq to NHibernate to load an object and eagerly
I have a problem using the SSIS. I try to import data from database
I have a problem using JSON and arrays. Here is my code: while($row =
i have a problem using the Catch Clipboard Events code found on this link
Greetings, I have a problem using jqgrid and jquery tab (I am coding in
I have the following problem using subversion: I'm currently working on the trunk of

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.