Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 August 1st, 2004, 01:50 PM
Authorized User
 
Join Date: Jul 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default Passing Session Variables to the Next Page

Hi All,

I need some help passing session variables from my login page to the next page. This is what I am trying to do:

- When users of the Human Resources Department access the next few pages via a login page, I want them to only see a button that is for Human Resources.
- Conversely, when users of the Information Services Department access the next few pages via a login page, I want them to only see a button that is for Information Services.

The order of the pages is as follows:
1.) Login Page
2.) Default Thank You Page (telling users that the login was successful)
3.) User Interface Page (where the user, depending on which department they are from, can only view specific buttons that pertain to their department).

I thought I was doing it correctly with the following code for the 'User Interface Page':

<MM:If runat="server"
Expression='<%#(session("sessDepartment")="HR")%>' >
<ContentsTemplate>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="108" height="46">
                      <param name="BGCOLOR" value="">
                      <param name="movie" value="HR Button (Dept Module).swf">
                      <param name="quality" value="high">
                      <embed src="HR Button (Dept Module).swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="108" height="46" ></embed>
                    </object>
</ContentsTemplate>
</MM:If>

On the page before (the 'Default Page'), I have the following script:

<script runat="server" language="VB">
Sub Page_Load()
Session("sessDepartment")=Request("hfDepartment")
Session("sessEditPages")=Request("hfEditPages")
End Sub
</script>

On the page before that, the 'Login Page', I have the following code which authenticates the Username. In my Access Database, I have two tables that are linked which should pull the Department that the username is from. Here is the Login Page code:
<%
if dsLogin.RecordCount > 0 then
Session("sessUsername") = Request.Form("tfUsername")
FormsAuthentication.RedirectFromLoginPage("tfUsern ame.value", true)
else if ((Request.Form("tfUsername"))) <> Nothing _
OR ((Request.Form("tfPassword"))) <> Nothing
Response.Write("Login Failed. Please Try Again.")
end if
%>

Any thoughts to why this is not working? Oh yeah, I'm using Dreamweaver as an application.
Thanks,
Jim



 
Old August 1st, 2004, 06:28 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

For FormsAuthentication.RedirectFromLoginPage("tfUsern ame.value", true)

it should be FormsAuthentication.RedirectFromLoginPage(tfUserna me.Text, true)

Since that will provide the user's user name when redirecting. In addition, instead of Request("<textbox>"), the ASP.NET approach is to do TextBox1.Text.

Brian
 
Old August 1st, 2004, 10:45 PM
Authorized User
 
Join Date: Jul 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Brian,

Thanks for your reply. I can't seem to get it working. I tried replacing the code with your suggestion, and the session variables are still not getting through.

I replied to your reply here:
http://p2p.wrox.com/topic.asp?TOPIC_ID=16951

I added the code, so that you can help me out. I am really stumped here. Anything help you could provide would be fantastic.

Thx,
Jim


 
Old August 2nd, 2004, 04:09 PM
Authorized User
 
Join Date: Jul 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Could anyone help me out with this problem?

Thx,
Jim

 
Old August 4th, 2004, 07:55 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

session is an object for ur IIS & can call from all pages that r running in that IIS! so there in no need to pass it.

Always:),
Hovik Melkomian.
 
Old August 6th, 2004, 12:14 AM
Authorized User
 
Join Date: Jul 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi All,

Absolutely great news. I got it working. : -)
Your not going to believe what happened. I actually had everything (the code that is) correct. I had a very good laugh when I figured out that my Firewall was blocking any access of my session variables. I turned my Firewall off and everything worked perfect.....absolutely perfect.

Well, I had a good laugh at myself. I should have known to turn off this program way before I started this webpage design.
Lesson learned I guess......

I just want to say thanks to all for taking the time to help out a beginner. Really appreciate it. I'm sure I'll get stuck on something else (hopefully not the easy stuff). This discussion board is great. Its saving me from pulling out my hair.

Thanks Again,
Jim








Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing session variables from login page. captainzorro Classic ASP Components 1 April 23rd, 2008 11:54 PM
Passing session variables from IIs to Tomcat aman thaper Internet Information Services 0 November 14th, 2006 09:34 AM
passing variables through session dmlocke Beginning PHP 4 May 4th, 2005 10:35 PM
Passing Session Variables to the Next Page [email protected] ASP.NET 1.0 and 1.1 Professional 1 August 1st, 2004 06:25 PM
Passing Session Variables to the Next Page [email protected] Classic ASP Databases 2 August 1st, 2004 01:59 PM





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