session variable question

Results 1 to 2 of 2

Thread: session variable question

  1. #1
    Join Date
    Dec 1969

    Default session variable question

    I&#039;m having a bit of a problem keeping my session variable values when a user enters information in multiple forms from multiple html pages. The variables aren&#039;t really needed untill various points in the program but by then they have disapeared because of what I assume as nothing is in the textboxes anymore from which the session variable came from. For Example: session("username")=request.form("txtUsername"). The variable will only be alive for a short time. Any subsequential pages after that that refer to "username" won&#039;t work. If anyone has an idea how to get around this, I would be gratefull.<BR>Thanks in advance.

  2. #2
    Join Date
    Dec 1969

    Default Probably your error

    Session variables *should* last from when they are assigned until the session terminates, meaning a minumum of 20 minutes, typically.<BR><BR>I&#039;d bet that <BR>(a) your code is inadvertently wiping them out after you&#039;ve set them. This would be easy to do if you do Session("x")=Request("x") without bothering to see if Request("x") actually has any value in it! <BR>*OR*<BR>(b) your code is spread across more than one virtual directory (more than one "application" in ASP terminology). I judge this inlikely if you are a newbie, as most newbies put all their pages in the same directory (even images and databases--which isn&#039;t really bad for getting started...just that you might want to get more sophisticated later). But it&#039;s possible.<BR><BR>So... Time to follow my mantra: DEBUG DEBUG DEBUG<BR><BR>I&#039;d suggest that you try to track down where the session value is being zapped by a simple mechanism:<BR><BR>At the top of *every* page that is involved, put in this code:<BR><BR>&#060;%<BR>For Each item In Session.Contents<BR>&nbsp; &nbsp; Response.Write "Session(" & item & ") has value " & Session(item) & "&lt;BR&#062;"<BR>Next<BR>%&#062;<BR>&#060;HR&#062 ;<BR><BR>That will dump the contents of *all* the current session variables to the screen, so you can begin to sort out what is going on. Do this before anything else on the page, so that &#060;TABLE&#062; and &#060;FONT&#062; and whatever tags don&#039;t muck you up.<BR><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