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. How to create variable that is accessible to all pages?

How to create variable that is accessible to all pages?

Scheduled Pinned Locked Moved ASP.NET
tutorialquestion
4 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.
  • M Offline
    M Offline
    mayl
    wrote on last edited by
    #1

    Hi How do you create variable that is accessible to all pages? I need to create variables to store username and password. I have tried using session variable, but session variable have a timeout. thank you

    C 1 Reply Last reply
    0
    • M mayl

      Hi How do you create variable that is accessible to all pages? I need to create variables to store username and password. I have tried using session variable, but session variable have a timeout. thank you

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      mayl wrote:

      I have tried using session variable, but session variable have a timeout.

      Then increase the time out. Remember that many many user sessions could be running simultaneously one one web application. If you store the values globally then everyone suddenly is logged in as the same person - A bit of a security risk I would hope you'll agree. The Session object is the correct place for storing data that is needed on each web page and across the lifetime of the [user] session. ColinMackay.net Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?

      M 1 Reply Last reply
      0
      • C Colin Angus Mackay

        mayl wrote:

        I have tried using session variable, but session variable have a timeout.

        Then increase the time out. Remember that many many user sessions could be running simultaneously one one web application. If you store the values globally then everyone suddenly is logged in as the same person - A bit of a security risk I would hope you'll agree. The Session object is the correct place for storing data that is needed on each web page and across the lifetime of the [user] session. ColinMackay.net Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?

        M Offline
        M Offline
        mayl
        wrote on last edited by
        #3

        How do you configure the session variables to expire only when the user close his/her browser instead of setting a time limit? I'm trying to impersonate this user/password, that are stored in the seesion variables, to execute a specific section of code. If the user stays idle for more than the session timeout, the impersonation does not work. thank you

        C 1 Reply Last reply
        0
        • M mayl

          How do you configure the session variables to expire only when the user close his/her browser instead of setting a time limit? I'm trying to impersonate this user/password, that are stored in the seesion variables, to execute a specific section of code. If the user stays idle for more than the session timeout, the impersonation does not work. thank you

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          Since web browsers do not notify the server when they are closed you cannot. You could persist this information (in an encrypted form) in a cookie that is stored on the user's PC. ColinMackay.net Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?

          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