473,396 Members | 1,995 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Losing Session Object

Can someone tell me why I'm losing my session variable when using
Response.Redirect? When I use the RedirectFromLoginPage method(currently
remmed out below), my session variable works fine, but I'm trying this
other way with Response.Redirect and it seems all my redirection works,
but it loses the session variable when I hit the redirected pages. Help
appreciated. Thanks. Here is code:

<code>

<%@ Import Namespace="System.Data.OleDB" %>

<%@ Import Namespace="System.Web.Security " %>

<%@ Page Language="vb" CodeBehind="login.aspx.vb"
AutoEventWireup="false" Inherits="LoginWithSessionVariables.login" %>

<HTML>

<script language="VB" runat="server">

Sub Login_Click(Src As Object, E As EventArgs)

If Page.IsValid Then

Dim strConn as string ="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
SOURCE=" & server.mappath("DB/WroxDBAuth.mdb") & ";"

Dim Conn as New OLEDBConnection(strConn)

Conn.Open()

Dim strSQL as string = "SELECT Pwd, Group FROM Tbl_MA_Users WHERE
Email = '" & txtEmail.Text & "'"

Dim Cmd as New OLEDBCommand(strSQL,Conn)

'Create a datareader, connection object

Dim Dr as OLEDBDataReader =
Cmd.ExecuteReader(System.Data.CommandBehavior.Clos eConnection)

Dim strGroup As String

'Get the first row and check the password.

If Dr.Read()

If Dr("Pwd").ToString = txtPwd.text Then

strGroup = Dr("Group").ToString

'FormsAuthentication.RedirectFromLoginPage(txtEmai l.Text, false)

FormsAuthentication.SetAuthCookie(txtEmail.Text, false)

Response.Redirect(strGroup)

Else

lblLoginMsg.text = "Invalid password."

End If

Else

lblLoginMsg.text = "Login name not found."

End If

Dr.Close

End If

Session("UserName") = txtEmail.Text
End Sub
</code>

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #1
0 958

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Scott Lyon | last post by:
I'm maintaining (read: I didn't write it, nor do I have the time to spend to rewrite it) an application that is suddenly giving me grief. The reason I say suddenly, is because we're in the...
4
by: Stephen | last post by:
I have a .NET (1.1 framework) application that is losing a session variable on only a few PC's. The main page is loading up in a frame in a Portal application. On the Page_Load it stores an...
2
by: Joe Molloy | last post by:
Hi, This isn't a mission critical question but I thought I'dl throw it out there for your feedback as it's a bit curious. I have developed a shopping cart for an application I'm working on...
4
by: Keith-Earl | last post by:
I have been writing ASP.NET apps since the RTM build and have never seen this. I built a simple app that uses session variables on my DEV laptop. All runs well. I have a simple toggle routine...
5
by: fbwhite | last post by:
I know this issue has been brought up many times, but I have tried many of the solutions to no avail. I wanted to give my specific case to see if someone could be of any help. We are using the...
9
by: Adrian Parker | last post by:
We have a website that works everywhere but on a few PCs on this one site.. Asp.Net 1.1 Server = Windows 2003 Client = XP In the web.config we use - cookieless="false" in the browser settings...
0
by: none | last post by:
Hi, I've got a problem with losing session state in ASP.NET version 2. It does it intermittently - sometimes it tanks - and sometimes it works OK. I've got the ASP.NET state service started...
4
by: Not Me | last post by:
Hi, I have a set of pages that use forms authentication for access. There are times when one of the session objects I'm using appears to disappear. The session is not timing out, however. (if...
5
by: chromis | last post by:
Hi there, I've recently been updating a site to use locking on application level variables, and I am trying to use a commonly used method which copies the application struct into the request...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.