Question about Session variables between pages

Results 1 to 2 of 2

Thread: Question about Session variables between pages

  1. #1
    Justin Bigelow Guest

    Default Question about Session variables between pages

    Hey all,<BR><BR>I seem to be having a problem passing a session variable between two pages. maybe somebody could tell me what I&#039m doing wrong. <BR>---------------------------------------------------------------<BR>dim intScore &#039total score that the user has accumulated<BR> intScore = Session("Score") &#039make it refrence a session var so the score can be passed<BR> intScore = 0 &#039initialize the score to zero<BR>----------------------------------------------------------------<BR>in a form I then check to see if a checkbox has been checked and if true, increment intScore.<BR>----------------------------------------------------------------<BR>&#060;input type=checkbox name="duties1"> <BR> &#060;% if duties1 = 1 then<BR> intScore = intScore + 1 <BR> end if&#037;&#062;<BR>----------------------------------------------------------------<BR>once the user submits I think that Session("Score") should be available to the "yourrating.asp" page, which I then use to give them a message and their score. <BR>----------------------------------------------------------------<BR>dim intScore &#039value to hold the score from form page<BR> intScore = Session("Score")<BR><BR> Response.Write intScore<BR>----------------------------------------------------------------<BR>I broke the return page down as simply as I could but I cannot seem to get it to work. Am I incorrectly testing the value of the checkbox or am I incorrectly passing the value of Session("Score"). Any help is appreciated. =)<BR><BR>Justin

  2. #2
    David Morgan Guest

    Default RE: Question about Session variables between pages

    Hi Justin<BR><BR>I think you have got slightly confused. Session variables are like any other in VBScript. You do not have to declare them before you use them.<BR><BR>In your example you do not set the variable intScore to the Session Var. after you have changed it.<BR><BR>So...<BR>------------------------------------<BR>intScore = 0 &#039 init the var<BR>If Session("Score") &#060;> "" Then<BR> intScore = CLng(Session("Score"))<BR>End If<BR>-------------------------------------<BR><BR>Then<BR><BR>-------------------------------------<BR>If Request.Form("duties1").Count > 0 Then<BR> intScore = intScore + 1<BR>End If<BR>Session("Score") = intScore<BR>-------------------------------------<BR><BR>Then write it to the page:<BR>like this &#060;%=Session("Score")&#037;&#062;<BR><BR>or <BR><BR>intScore = CLng(Session("Score"))<BR>Response.Write(intScore) <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