Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - session state not sticking
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

session state not sticking

 Post Reply Post Reply
Author
carrathanatos View Drop Down
Newbie
Newbie
Avatar

Joined: 26 June 2008
Location: phx, az
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote carrathanatos Quote  Post ReplyReply Direct Link To This Post Topic: session state not sticking
    Posted: 26 June 2008 at 3:11pm
When I set my session variables, and then move to the next page with my new found credentials, it doesn't keep them.

I'm moving from login.asp using check.asp which should bring me to panel.asp.

login.asp:

<html>
<head>
<title>Login</title>
</head>
<body>
<% Session.Abandon %>
<form name="form" action="check.asp" method="post">
Username: <input type="text" name="username" />
Password: <input type="password" name="password" />
<input type="hidden" name="login" value="true" />
<input type="submit" value="login" />
</form>
</body>
</html>


check.asp:


<%
Dim adoCon
Dim rsLogin
Dim strSQL
Dim username
Dim passwordForm
Dim passwordDB


Session.Abandon
username = Request.Form("username")
passwordForm = Request.Form("password")

Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("login.mdb")
Set rsLogin = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT tblLoginInfo.ID_no, tblLoginInfo.loginName, tblLoginInfo.loginCode, tblLoginInfo.permissionLevel, tblLoginInfo.fName, tblLoginInfo.lName FROM tblLoginInfo;"
rsLogin.Open strSQL, adoCon


Do While (not rsLogin.EOF) AND (rsLogin("loginName") <> username)
    rsLogin.MoveNext
Loop
    
if(rsLogin("loginCode") = passwordForm) Then
        ENABLESESSIONSTATE = TRUE
        response.write("pass")
        Session("timeVisited") = Time()
       
        Session("permission") = rsLogin("permissionLevel")
        Session("name1") = rsLogin("fName")
        Session("name2") = rsLogin("lName")
        response.write(session("permission"))
        response.write(session("name1"))
        response.write(session("name2"))
        response.write(session.timeout)
        response.redirect "panel.asp"
    else
        response.write("fail")
    end if

Session.Abandon

rsLogin.Close
Set rsLogin = Nothing
Set adoCon = Nothing


%>
<!-- Link to test session state:
<a href="session.asp">session</a>
-->


panel.asp:

<%
If IsEmpty(Session("name1")) then
    response.redirect "login.asp"
end if
%>


<html>
<head>
<title>Job Opportunities Panel</title>
<link rel="stylesheet" type="text/css"
href="m1-5.css" />
</head>
<body>

<table id="maintable" align="center">
    <tr>
        <td colspan="2" height="50" id="banner">
            <img src="jobBanner.png" />
        </td>
    </tr>
    <tr >
        <td height="400" id="navigation" valign="top" align="left">

Hello (username)<br>
Logout<br>
Change Password<br>
<a href="add.asp">Add New Posting</a>

</td><td id="content" valign="top" align="left">
<%
Dim adoCon
Dim rsJobs
Dim strSQL
Dim itemID

Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("jobOps.mdb")
Set rsJobs = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT tblJobs.ID_no, tblJobs.jobTitle, tblJobs.jobLocation, tblJobs.jobSalary, tblJobs.payType FROM tblJobs;"
rsJobs.Open strSQL, adoCon

Do While not rsJobs.EOF
    Response.Write("<br />")
    Response.Write(rsJobs("jobTitle"))
    Response.Write(" (")
    Response.Write(rsJobs("jobLocation"))
    Response.Write(") - ")
    Response.Write("<a href=""delete_entry.asp?ID=" & rsJobs("ID_no") & """>Delete</a>")
    Response.Write(" | ")
    Response.Write("<a href=""update_form.asp?ID=" & rsJobs("ID_no") & """>Edit</a>")
    Response.Write("<br />Pay: ")
    Response.Write(rsJobs("jobSalary"))
    Response.Write("/")
    Response.Write(rsJobs("payType"))
    Response.Write("<br />")
    Response.Write("<hr width=""80%"" height=""1"" />")
    Response.Write("<br />")
    rsJObs.MoveNext
Loop

rsJobs.Close
Set rsJobs = Nothing
Set adoCon = Nothing
%>
</td></tr></table>
</body>
</html>


I have checked on my server and session states are enabled.  I am using Firefox and cookies are enabled.

I can't find any other resources out there to troubleshoot this, so maybe you guys can help... Confused
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post Posted: 26 June 2008 at 3:34pm
You want to remove the Session.Abandon part as this drops any sessions that are currently running for your web site loosing any data that they hold. Session.Abandon should always be avoided.

If you need to destroy a session variable after you finish using it use:-

Session.Contents.Remove("Variable_name_here")
Back to Top
carrathanatos View Drop Down
Newbie
Newbie
Avatar

Joined: 26 June 2008
Location: phx, az
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote carrathanatos Quote  Post ReplyReply Direct Link To This Post Posted: 26 June 2008 at 4:24pm
nevermind, I figured it out... I took out the session.abandon in check.asp, because while I thought I was clearing any existing sessions, it actually doesn't take effect until the next page... effectively erasing my session.
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.