session security check problem

Results 1 to 2 of 2

Thread: session security check problem

  1. #1
    Join Date
    Dec 1969

    Default session security check problem

    I&#039;ve got a page that when a user logs in, it creates a session called security with a number indicating their security level. This code is not working and I don&#039;t know why.<BR><BR>if session("Security") = 2 then<BR> response.write "You&#039;re allowed in."<BR>end if<BR><BR>If (Session("Valid") = "") or (cint(Session("Security")) &#060;= 4) or (cint(session("Security")) &#062;= 2) Then<BR>response.write session("Security") & " You don&#039;t belong here."<BR>response.end<BR><BR>When I log in, I have the security level of 2. The first if statement prints out "You&#039;re allowed in" successfully. then when it hits the 2nd if, it then prints out, "2 You don&#039;t belong here." Obviously my session is equal to 2, but for some reason it&#039;s not comparing correctly or something. What could I be doing wrong? Thanks. Oh, and yes, my other session("valid") is not empty, so that&#039;s not an issue. Thanks.

  2. #2
    Join Date
    Dec 1969
    Los Angeles, CA

    Default RE: session security check problem

    If your Session("Security") = 2<BR>then don tyou thingk this will be true ALSO (cint(Session("Security")) &#060;= 4) ????<BR><BR><BR>try this<BR><BR><BR>if session("Security") = 2 then<BR>response.write "You&#039;re allowed in."<BR>elseIf (Session("Valid") = "") or (cint(Session("Security")) &#060;= 4) or (cint(session("Security")) &#062;= 2) Then<BR>response.write session("Security") & " You don&#039;t belong here."<BR>response.end<BR>end if<BR><BR><BR><BR>i also nice you are doing a cint(Session("Security")) what do you think will happen if for some reason Session("Security") = "" are you talking care of that to ensire it will NEVER be "" or a string??<BR><BR><BR>oh and instead of cint use clng....though you numbers may never get that long it would be better if you made clng a habbit<BR><BR><BR>and make THIS your first if<BR>if clng("0" & session("Security")) = 2 then<BR><BR>that is if you want to take care of the "" in the variable AND it MAY be better convert into clng BEFORE you compare it with a number.<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