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. session variables

session variables

Scheduled Pinned Locked Moved ASP.NET
questioncsharpdatabasesalesjson
5 Posts 5 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.
  • S Offline
    S Offline
    sc steinhayse
    wrote on last edited by
    #1

    I have a question about using session variables since this is the first C# 2010 web form app that I am running. Right now I am passing 3 session variables between 2 web pages in the web application that I setup. This is a data entry application where some information is entered on page 1 and the rest of the information is entered on page 2. When the user has finished entering the information for the first customer. Now the user will be ready to setup information for the second user. From what I have seen on the internet session variables last up to 20 minutes. Thus I basically do not want the information saved from customer 1 to be entered into the database file for customer 2 by using session variables. Thus to prevent this from occuring, I am coding the following before the user clicks the button to enter data for the next customer:

    Session.Remove("var1");

    Session.Remove("var2");

    Session.Remove("var3");

    Response.Redirect("~/page1.aspx");

    Can you tell me if this is the best method for clearing out session variables and/or if there is a better process you would recommend? Can you tell me and/or point me to a reference that will explain your answer to me?

    W R J L 4 Replies Last reply
    0
    • S sc steinhayse

      I have a question about using session variables since this is the first C# 2010 web form app that I am running. Right now I am passing 3 session variables between 2 web pages in the web application that I setup. This is a data entry application where some information is entered on page 1 and the rest of the information is entered on page 2. When the user has finished entering the information for the first customer. Now the user will be ready to setup information for the second user. From what I have seen on the internet session variables last up to 20 minutes. Thus I basically do not want the information saved from customer 1 to be entered into the database file for customer 2 by using session variables. Thus to prevent this from occuring, I am coding the following before the user clicks the button to enter data for the next customer:

      Session.Remove("var1");

      Session.Remove("var2");

      Session.Remove("var3");

      Response.Redirect("~/page1.aspx");

      Can you tell me if this is the best method for clearing out session variables and/or if there is a better process you would recommend? Can you tell me and/or point me to a reference that will explain your answer to me?

      W Offline
      W Offline
      wikizhao
      wrote on last edited by
      #2

      try to use session timeout.Sometime,network is not well and session has not remove.

      1 Reply Last reply
      0
      • S sc steinhayse

        I have a question about using session variables since this is the first C# 2010 web form app that I am running. Right now I am passing 3 session variables between 2 web pages in the web application that I setup. This is a data entry application where some information is entered on page 1 and the rest of the information is entered on page 2. When the user has finished entering the information for the first customer. Now the user will be ready to setup information for the second user. From what I have seen on the internet session variables last up to 20 minutes. Thus I basically do not want the information saved from customer 1 to be entered into the database file for customer 2 by using session variables. Thus to prevent this from occuring, I am coding the following before the user clicks the button to enter data for the next customer:

        Session.Remove("var1");

        Session.Remove("var2");

        Session.Remove("var3");

        Response.Redirect("~/page1.aspx");

        Can you tell me if this is the best method for clearing out session variables and/or if there is a better process you would recommend? Can you tell me and/or point me to a reference that will explain your answer to me?

        R Offline
        R Offline
        Rahul Rajat Singh
        wrote on last edited by
        #3

        Looking into the above description, i could make 2 things. 1. you have some session variables that you are using for custom logic. now you want to use session["var1"] for filling customer1 information. 2. you might have some session variables that are required for maintaining user sessions. (probably) and perhaps with the same user ID you will have to use the same session variables with separate set of data. Session.Remove("var1"); for all the variables should work once you save the data into database. but in case you dont have the requirement mentioned in #2 point i.e. maintaining user session then instead of clearing the variables one by one you can simply do a session.Abandon too. in short, if you are not using sessions to track the login status then you can use session.abandon too.

        Every now and then say, "What the Elephant." "What the Elephant" gives you freedom. Freedom brings opportunity. Opportunity makes your future.

        1 Reply Last reply
        0
        • S sc steinhayse

          I have a question about using session variables since this is the first C# 2010 web form app that I am running. Right now I am passing 3 session variables between 2 web pages in the web application that I setup. This is a data entry application where some information is entered on page 1 and the rest of the information is entered on page 2. When the user has finished entering the information for the first customer. Now the user will be ready to setup information for the second user. From what I have seen on the internet session variables last up to 20 minutes. Thus I basically do not want the information saved from customer 1 to be entered into the database file for customer 2 by using session variables. Thus to prevent this from occuring, I am coding the following before the user clicks the button to enter data for the next customer:

          Session.Remove("var1");

          Session.Remove("var2");

          Session.Remove("var3");

          Response.Redirect("~/page1.aspx");

          Can you tell me if this is the best method for clearing out session variables and/or if there is a better process you would recommend? Can you tell me and/or point me to a reference that will explain your answer to me?

          J Offline
          J Offline
          jkirkerx
          wrote on last edited by
          #4

          I would check to see if the session exist first before removal, so you don't generate a object does not exist error. [EDIT] wrap code in tags

          If Not Sesson("var1") Is Nothing Then
          Session.Remove("var1")
          End If

          1 Reply Last reply
          0
          • S sc steinhayse

            I have a question about using session variables since this is the first C# 2010 web form app that I am running. Right now I am passing 3 session variables between 2 web pages in the web application that I setup. This is a data entry application where some information is entered on page 1 and the rest of the information is entered on page 2. When the user has finished entering the information for the first customer. Now the user will be ready to setup information for the second user. From what I have seen on the internet session variables last up to 20 minutes. Thus I basically do not want the information saved from customer 1 to be entered into the database file for customer 2 by using session variables. Thus to prevent this from occuring, I am coding the following before the user clicks the button to enter data for the next customer:

            Session.Remove("var1");

            Session.Remove("var2");

            Session.Remove("var3");

            Response.Redirect("~/page1.aspx");

            Can you tell me if this is the best method for clearing out session variables and/or if there is a better process you would recommend? Can you tell me and/or point me to a reference that will explain your answer to me?

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Use session.Abandon

            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