Using Session vs. database

Results 1 to 3 of 3

Thread: Using Session vs. database

  1. #1
    Join Date
    Dec 1969

    Default Using Session vs. database

    I know I&#039m picking up the same can of worms we dropped yesterday, but I wanted to know if anyone can speak from experience about the pros and cons of using Session variables versus a database to maintain state for a user in ASP. <BR><BR>We&#039re using Access and it is a pretty low-volume site, but it seems to me that the Session variables are much faster than a database would be. Unfortunately, I cannot control the environment in a significant enough way that I could perform my own tests, so as always - any and all input appreciated!<BR><BR>Thanks, <BR><BR>Dawn

  2. #2
    Matt Jacyno Guest

    Default RE: Using Session vs. database

    Weeeeeell, since the can of worms is open.. ;)<BR><BR>In my opinion, you should always do what makes sense. Yes, Session variables are evil. But so is putting data that doesn&#039t need to be persistent into database. So, with that in mind:<BR><BR>If you...<BR>A) ...have a small number of values you want to keep around that do not need to be persistent, go ahead and use Session vars. (I&#039m assuming you&#039re just storing strings and the like - NO objects ;-} )<BR>B) ...have user-specific data the NEEDS to be persistent, then certainly you need a database. But that&#039s certainly not the case, or else you&#039d already be taking that road.<BR><BR>The main point I want to make is that storing data in a database doesn&#039t always make sense. There are ways to get around using Session vars to keep information, if you choose - for example, you could write hidden form elements to every page, and then retrieve them on every ASP page, if you wanted to.<BR><BR>At the risk of being repetitive, just do what makes sense. :)<BR>Matt

  3. #3
    Join Date
    Dec 1969

    Default Thanks, Matt

    Thanks for the idea of hidden elements...I was already using them for storing other info but did not think of it as a solution for this. It sounds like a possibility. <BR><BR>Considering the needs of this particular scenario, I don&#039t need the database, there are no objects, and so I think we will debate going with Session variables vs. hidden elements. <BR><BR>The issue with Session variables is the browser setting for cookies being off, but the issue with hidden elements is the need to keep passing them on and on.<BR><BR>Win-win, as always...<BR><BR>Thanks!<BR>

Posting Permissions

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