Page works fine, until I add Session Variables

Results 1 to 2 of 2

Thread: Page works fine, until I add Session Variables

  1. #1
    DavidM Guest

    Default Page works fine, until I add Session Variables

    Ok I have a simple logon page that only has username and password. <BR><BR>That info gets passed to this page where I have this code:<BR><BR>&#060;%<BR>username = TRIM( Request("username"))<BR>password = TRIM( Request("password"))<BR>IF username = "" OR password ="" THEN<BR> Response.Redirect "logon.asp"<BR>Else <BR> Session("username") = Request.Form("username")<BR> Session("password") = Request.Form("password")<BR>END IF<BR>%&#062;<BR><BR>This is nothing hard, all this does is take the contents of "username" and "password" and stores them as session variables. Then I have specific INCLUDE PAGE code that relates to the logon username. I won&#039t post that code because it isn&#039t relevant.<BR><BR>The premise is I do not want people to have to relog in if they search through the page and click on the home button. So i changed my code to this:<BR><BR>&#060;%<BR>If Session("username") = "" and Session("password") = "" Then<BR>%&#062;<BR> <BR> &#060;%<BR> username = TRIM( Request("username"))<BR> password = TRIM( Request("password"))<BR> IF username = "" OR password ="" THEN<BR> Response.Redirect "logon.asp"<BR> Else <BR> Session("username") = Request.Form("username")<BR> Session("password") = Request.Form("password")<BR> END IF<BR> %&#062;<BR> <BR>&#060;%<BR>Elseif Session("username") &#060;&#062; "" and Session("password") &#060;&#062; "" Then<BR>%&#062; <BR><BR>&#060;!--OTHER CODE--&#062;<BR><BR>&#060;%End IF%&#062;<BR><BR>Now this is just some handling that checks to see if the session variables exisist, if it doesn&#039t then it creates them. If it does then it continues to process the page. But instead of processing those INCLUDE PAGES imediately, all I get is a white page, once the page is refreshed, the INCLUDE PAGES work. <BR><BR>I don&#039t understand that? Where would the code be stopping the first time to cause this?

  2. #2
    Join Date
    Dec 1969

    Default RE: Page works fine, until I add Session Variables

    couldn&#039t say really. looks OK, but then, you haven&#039t included the code in the middle. have you tried view-&#062;source? occassionally an error gets hidden in the source code. also, write a script which displays ALL session contents, then you can see what&#039s going on behind the scenes<BR><BR>BTW<BR>don&#039t use so many context switches (%&#062;&#060;%) - if the delimiters have no HTML output between them, get rid of them.<BR><BR>j

Posting Permissions

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