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. Other Discussions
  3. The Weird and The Wonderful
  4. How To Use Session Variables

How To Use Session Variables

Scheduled Pinned Locked Moved The Weird and The Wonderful
databasetutorial
14 Posts 11 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.
  • A Offline
    A Offline
    AnalogNerd
    wrote on last edited by
    #1

    I'm re-writing a legacy ASP application. There's an expensive call to an external webservice and a database to determine a calculated setting specific to the person logged in. On the first page this calculation is done and the result is stored in a session variable. On every subsequent page the session variable is ignore, the value is recalculated and then stored in the session variable again! Some days I don't know if to laugh or cry.

    OriginalGriffO I L R U 5 Replies Last reply
    0
    • A AnalogNerd

      I'm re-writing a legacy ASP application. There's an expensive call to an external webservice and a database to determine a calculated setting specific to the person logged in. On the first page this calculation is done and the result is stored in a session variable. On every subsequent page the session variable is ignore, the value is recalculated and then stored in the session variable again! Some days I don't know if to laugh or cry.

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      Sometimes, you just want to go into a code review with a baseball bat and a spiked glove... :sigh:

      The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      1 Reply Last reply
      0
      • A AnalogNerd

        I'm re-writing a legacy ASP application. There's an expensive call to an external webservice and a database to determine a calculated setting specific to the person logged in. On the first page this calculation is done and the result is stored in a session variable. On every subsequent page the session variable is ignore, the value is recalculated and then stored in the session variable again! Some days I don't know if to laugh or cry.

        I Offline
        I Offline
        imagiro
        wrote on last edited by
        #3

        Cool, who ever wrote the code invented the write-only variable.. What shall we call it? "Wrariable"?

        A B 2 Replies Last reply
        0
        • I imagiro

          Cool, who ever wrote the code invented the write-only variable.. What shall we call it? "Wrariable"?

          A Offline
          A Offline
          AnalogNerd
          wrote on last edited by
          #4

          That kind of innovation must be why this guy is now a manager. My only solace in that is that he's no longer writing "code".

          I B 2 Replies Last reply
          0
          • A AnalogNerd

            That kind of innovation must be why this guy is now a manager. My only solace in that is that he's no longer writing "code".

            I Offline
            I Offline
            imagiro
            wrote on last edited by
            #5

            He's a manager now? Well, that explains a lot. I know quite some managers who also write (or wrote) code, and that was among the most horrible code I've ever seen. Think you still might find examples here in TWATW.

            C 1 Reply Last reply
            0
            • I imagiro

              He's a manager now? Well, that explains a lot. I know quite some managers who also write (or wrote) code, and that was among the most horrible code I've ever seen. Think you still might find examples here in TWATW.

              C Offline
              C Offline
              ClockMeister
              wrote on last edited by
              #6

              imagiro wrote:

              He's a manager now? Well, that explains a lot. I know quite some managers who also write (or wrote) code, and that was among the most horrible code I've ever seen. Think you still might find examples here in TWATW.

              Remember the old saying: "Those that can't do, manage!" Update: LOL ... Isfeasachme, whoever that is, just posted a flaming reply to my message. Listen sport, I have been writing code probably since you were born, enough with the sanctimony. I've seen plenty of inept management in my days and very frequently they were coder's who couldn't hack it (no pun intended). As sharp as you are, you couldn't refrain from a flame which was copied to my inbox before you removed same. Chill out man! ;)

              I 1 Reply Last reply
              0
              • A AnalogNerd

                I'm re-writing a legacy ASP application. There's an expensive call to an external webservice and a database to determine a calculated setting specific to the person logged in. On the first page this calculation is done and the result is stored in a session variable. On every subsequent page the session variable is ignore, the value is recalculated and then stored in the session variable again! Some days I don't know if to laugh or cry.

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

                Yeah, I work with a guy who puts whole serialized datasets in session variables. And I can't even complain about it to the big boss, because they are kinda buddies.

                1 Reply Last reply
                0
                • C ClockMeister

                  imagiro wrote:

                  He's a manager now? Well, that explains a lot. I know quite some managers who also write (or wrote) code, and that was among the most horrible code I've ever seen. Think you still might find examples here in TWATW.

                  Remember the old saying: "Those that can't do, manage!" Update: LOL ... Isfeasachme, whoever that is, just posted a flaming reply to my message. Listen sport, I have been writing code probably since you were born, enough with the sanctimony. I've seen plenty of inept management in my days and very frequently they were coder's who couldn't hack it (no pun intended). As sharp as you are, you couldn't refrain from a flame which was copied to my inbox before you removed same. Chill out man! ;)

                  I Offline
                  I Offline
                  Isfeasachme
                  wrote on last edited by
                  #8

                  I love how you punk know-it-all coders who havent an ounce of business experience jump on disrespect for managers. My job as a manager is to keep the shitstorm of indecision and wildly fluctuating targets from disrupting your pretty little land of unicorns and code. The corporate world just past the tip of your nose could care a smear of crap about your elegant solution that took 4x 2-liter caffeinated days to figure out. They don't get code reviews, buggy compilers, platform quirks, scalability or error trapping. All that blather means to them is more time and money "wasted". I get the joy of "selling" the idea that the prototype demo, while working for the presentation is still 3 months out from production. If you are lucky, we are coders and can empathize with you, but coding is not revenue and revenue is what pays your salary. If you so much as open your mouth to argue that point, I will offshore your job to some guys who turn out shitty, useless code that barely works because that is what everyone above my head thinks they want. :mad::mad::mad:

                  1 Reply Last reply
                  0
                  • A AnalogNerd

                    I'm re-writing a legacy ASP application. There's an expensive call to an external webservice and a database to determine a calculated setting specific to the person logged in. On the first page this calculation is done and the result is stored in a session variable. On every subsequent page the session variable is ignore, the value is recalculated and then stored in the session variable again! Some days I don't know if to laugh or cry.

                    R Offline
                    R Offline
                    RafagaX
                    wrote on last edited by
                    #9

                    You never know, maybe the external system changed its mind after the first call to it... :rolleyes:

                    CEO at: - Rafaga Systems - Para Facturas - Modern Components for the moment...

                    1 Reply Last reply
                    0
                    • I imagiro

                      Cool, who ever wrote the code invented the write-only variable.. What shall we call it? "Wrariable"?

                      B Offline
                      B Offline
                      Bob1000
                      wrote on last edited by
                      #10

                      Think the write only variable is probably related to 'Planck's variable constant' - something that that we used to make physics experiments work during school labs!

                      1 Reply Last reply
                      0
                      • A AnalogNerd

                        That kind of innovation must be why this guy is now a manager. My only solace in that is that he's no longer writing "code".

                        B Offline
                        B Offline
                        BrainiacV
                        wrote on last edited by
                        #11

                        AnalogNerd wrote:

                        My only solace in that is that he's no longer writing "code".

                        I had the same feelings about my former Bitch Supervisor From Helltm. She barely understood coding concepts and management recognized that she knew enough to be dangerous and she was good at cracking the whip, so she was promoted to supervisor. She was terribly insecure and terrified that I wanted her job (I didn't) and compensated by being a total control freak. Those of us on her team have hours of stories we could tell about her incompetence. I always said that if her manager had ever come to an abrupt halt, they'd need an emergency room proctologist to save her. Instead she was eventually promoted to be the assistant to the new technology vice-president. However after the company realized he was only a hot bag of buzzwords and equally incompetent, he was given the boot and she was out the door shortly after.

                        Psychosis at 10 Film at 11 Those who do not remember the past, are doomed to repeat it. Those who do not remember the past, cannot build upon it.

                        J 1 Reply Last reply
                        0
                        • B BrainiacV

                          AnalogNerd wrote:

                          My only solace in that is that he's no longer writing "code".

                          I had the same feelings about my former Bitch Supervisor From Helltm. She barely understood coding concepts and management recognized that she knew enough to be dangerous and she was good at cracking the whip, so she was promoted to supervisor. She was terribly insecure and terrified that I wanted her job (I didn't) and compensated by being a total control freak. Those of us on her team have hours of stories we could tell about her incompetence. I always said that if her manager had ever come to an abrupt halt, they'd need an emergency room proctologist to save her. Instead she was eventually promoted to be the assistant to the new technology vice-president. However after the company realized he was only a hot bag of buzzwords and equally incompetent, he was given the boot and she was out the door shortly after.

                          Psychosis at 10 Film at 11 Those who do not remember the past, are doomed to repeat it. Those who do not remember the past, cannot build upon it.

                          J Offline
                          J Offline
                          jcmaida
                          wrote on last edited by
                          #12

                          There are millions of write only variables in code is use daily. I bet you have some in your own code right now. For the database problem, someone intended to use the variable, but either forgot it was there or it was unknown to next programmer in line.

                          1 Reply Last reply
                          0
                          • A AnalogNerd

                            I'm re-writing a legacy ASP application. There's an expensive call to an external webservice and a database to determine a calculated setting specific to the person logged in. On the first page this calculation is done and the result is stored in a session variable. On every subsequent page the session variable is ignore, the value is recalculated and then stored in the session variable again! Some days I don't know if to laugh or cry.

                            U Offline
                            U Offline
                            User 8786325
                            wrote on last edited by
                            #13

                            I am relatively new to this sort of thing and I currently use a different language but reading this thread makes me wonder if there is an issue with using session variables? I am upgrading a program that currently uses POST method to transfer small portions of data between screens and I want to reduce the number of screens and to do this I need to transfer larger data sets. Using Session variables seem like a better idea since they are more persistent and are there through the whole session. For the original poster it would seem that it would be easy to check the session variable to see if it exists and if it doesn't then calculate it otherwise use the session variable and continue? Seems like a simple bug to fix to me. But I only have experience with PHP with this at this point and am still learning. I have not even attempted to learn ASP.

                            A 1 Reply Last reply
                            0
                            • U User 8786325

                              I am relatively new to this sort of thing and I currently use a different language but reading this thread makes me wonder if there is an issue with using session variables? I am upgrading a program that currently uses POST method to transfer small portions of data between screens and I want to reduce the number of screens and to do this I need to transfer larger data sets. Using Session variables seem like a better idea since they are more persistent and are there through the whole session. For the original poster it would seem that it would be easy to check the session variable to see if it exists and if it doesn't then calculate it otherwise use the session variable and continue? Seems like a simple bug to fix to me. But I only have experience with PHP with this at this point and am still learning. I have not even attempted to learn ASP.

                              A Offline
                              A Offline
                              AnalogNerd
                              wrote on last edited by
                              #14

                              What you say is what should have been done. The code should check the session variable, if it is null then go to the database and 3rd party API and calculate the value needed, and store it in the session variable for later use. In this way it's basically using the session variable for caching a value that is expensive to calculate and doesn't change often. I posted this because what the person who actually wrote this did was kind of a face-palm moment. They write the value into the session variable and then never read from the session variable again. Every time this value was needed they calculated it, then wrote the calculated value into the session variable only to never retreive it and do anything with it.

                              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