Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 1.0
This is the forum to discuss the Wrox book Beginning ASP.NET 1.0 with C# by Chris Goode, John Kauffman, Christopher L. Miller, Neil Raybould, S. Srinivasa Sivakumar, Dave Sussman, Ollie Cornes, Rob Birdwell, Matt Butler, Gary Johnson, Ajoy Krishnamoorthy, Juan T. Llibre, Chris Ullman; ISBN: 9780764543708
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 1.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 27th, 2003, 02:54 PM
Registered User
 
Join Date: Jul 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Trouble with session states

I'm trying to go beyond what the book covers with session states but am not getting very far. I am setting the session state on one page, then checking to see if it exists on another. However, it's not working. Below is the code that I am using the check to see if the session state is present, and then what conditions to take based on that. The only condition that will take place is the very last one, which should be the result if the session hasn't been set. Any help would be appreciated.

<script language="vb" runat="server">
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)

Dim SessionId As Long
Dim userClass

'Determine if User is logged in

Try
SessionId = Session.SessionID

 If SessionId <> "" then

  userClass = Session("class").ToString()
  company.text = Session("company").ToString()
  expirationDate.text = Session("expiration").ToString()

    If userClass <> "Client" OR userClass <> "Administrator" then
     Response.Redirect("/debug/notaccepted.html")
    End If

 Else

  Response.Redirect("/debug/accepted.html")

 End If

Catch excp as Exception

  Response.Redirect("/debug/notset.html")

End Try

End Sub
</script>

 
Old October 27th, 2003, 03:29 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

It looks like you have an OR Vs AND problem:
Code:
If userClass <> "Client" OR userClass <> "Administrator" then
  Response.Redirect("/debug/notaccepted.html")
End If
Imagine a user with a userClass of Client. The first statement will then return false (userClass *is* Client) but the second statement will return true (Client <> Administrator)

I think it should be like this:
Code:
If userClass <> "Client" And userClass <> "Administrator" then
  Response.Redirect("/debug/notaccepted.html")
End If
This way, if a user is not a Client and not an Administrator, he or she gets redirected away.

Does that make sense?

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old October 28th, 2003, 09:46 AM
Registered User
 
Join Date: Jul 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar,

Thank you for pointing that out. Unfortunatly I am still having the same problem. I know the session variables are being accepted because I can comment most of that code and assign them to a label. I'll keep playing with it and see what I can come up with. Thanks.






Similar Threads
Thread Thread Starter Forum Replies Last Post
objects and states deepak Java Basics 7 June 26th, 2008 03:26 AM
Session IDs Causing Trouble When Webtesting VSTS08 matt.m Visual Basic 2008 Essentials 0 March 20th, 2008 09:52 AM
Ironic session trouble. joop Beginning PHP 4 February 2nd, 2005 01:32 PM
Having trouble with Maintaining Session State kmattera Classic ASP Basics 0 December 7th, 2004 08:47 PM
Session States, Global. asax and web.config ohmbhu General .NET 2 July 1st, 2004 09:15 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.