Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - problem with session variables
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

problem with session variables

 Post Reply Post Reply
Author
jharnisch View Drop Down
Newbie
Newbie


Joined: 18 April 2004
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote jharnisch Quote  Post ReplyReply Direct Link To This Post Topic: problem with session variables
    Posted: 18 April 2004 at 9:55am
Hello,

I am having a problem I think with session variables. On a page I have 4 buttons a user can click from and each of those buttons has a random number associated with it. When the timer reaches zero, one of the buttons is able to be clicked on and a user earns a credit. It works most of the time, However some times it does not store the correct random number for the button. Here is some of the code:

This picks which button will be allowed to click on:

Randomize Timer 'Randomize Function
rndNumber = Int((RND * 4)+1)

If rndNumber = 1 then
Session("KeyCheck") = rndKey1
End If

If rndNumber = 2 then
Session("KeyCheck") = rndKey2
End If

If rndNumber = 3 then
Session("KeyCheck") = rndKey3
End If

If rndNumber = 4 then
Session("KeyCheck") = rndKey4
End If

This next part then takes the random number associated with the button the user clicks and compares it to button that was chosen:

If Request("Encrypt") <> Session("KeyCheck") Then

If it does not match the user is taken back to the logon screen. I cannot figure out why it works most of the time and then there are a few times where the user gets redirected back to the login page even though they clicked on the correct button.

Any help would be appreciated,

Jeff Harnisch
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 18 April 2004 at 11:35am
Sessions a cookies, it may be that the user is denying the cookie.
Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Post Options Post Options   Thanks (0) Thanks(0)   Quote dj air Quote  Post ReplyReply Direct Link To This Post Posted: 18 April 2004 at 11:41am

it also could be that the rndNumber generated is bigger than 4,

have you response.write rndNumber

which will give you the rndNumber number that has been generated

Back to Top
pmormr View Drop Down
Senior Member
Senior Member


Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
Post Options Post Options   Thanks (0) Thanks(0)   Quote pmormr Quote  Post ReplyReply Direct Link To This Post Posted: 18 April 2004 at 12:43pm

why don't you change this...

If rndNumber = 1 then
Session("KeyCheck") = rndKey1
End If

If rndNumber = 2 then
Session("KeyCheck") = rndKey2
End If

If rndNumber = 3 then
Session("KeyCheck") = rndKey3
End If

If rndNumber = 4 then
Session("KeyCheck") = rndKey4
End If

into this...

Select Case rndNumber
   Case 1:
      Session("KeyCheck") = rndKey1
   Case 2:
      Session("KeyCheck") = rndKey2
   Case 3:
      Session("KeyCheck") = rndKey3
   Case 4:
      Session("KeyCheck") = rndKey4
End Select

that makes it a little easier to read... btw... don't whine if it gives you an error... i'm not sure if you need the colin after the case 1... stuff

Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 18 April 2004 at 12:45pm
You don't need a colon, remove the colon after case x
Back to Top
jharnisch View Drop Down
Newbie
Newbie


Joined: 18 April 2004
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote jharnisch Quote  Post ReplyReply Direct Link To This Post Posted: 19 April 2004 at 3:38pm

The problem isnt with generating the random number. It picks a number from 1 to 4. Any other ideas?

Thanks

 

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.