Quick question about Session object

Results 1 to 2 of 2

Thread: Quick question about Session object

  1. #1
    Ben Roy Guest

    Default Quick question about Session object

    I&#039m just wondering is it expensive to grab the value of a session variable? I am storing a single ID in each session, and I&#039m just wondering if I should be using Session("UserID") throughout my page or if I should be doing:<BR><BR>UserID = SEssion("UserID")<BR><BR>and then using UserID throughout my page. We can go back and forth about style but I&#039m just wondering from a performance perspective if it has any impact.

  2. #2
    Joel Nelson Guest

    Default RE: Quick question about Session object

    It&#039s expensive to use session variables in the first place, but they are, admittedly, a necessary evil sometimes. The only reason that assigning them to a local variable *might* be slightly more efficient, especially if you use the value many times in the same page, is because the session object is, I *think* an associative array and doing lookups would cause it to burn up a few extra CPU clicks identifying which array member you were dereferencing. I&#039m not sure, but just from the standpoint of writing cleaner, easier to read code I think I would make the assignment at the top and use a local variable, rather than go back to the session object each time.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts