473,287 Members | 1,564 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,287 software developers and data experts.

Login Logout question

Hiya, i made a asp page, and one of my divs (as a include) is as below. the problem is if the main page is resubmitted, i get logged out again?...

heres the code.. i think its on the value=true for the hidden textbox on the logout sub.. but how do i get round this? can i not change the value onclick?


<div id=Rightbody>
<!--<form id="RightBodyForm" name="RightbodyForm" method="post" action="Guestbook2.asp">-->
<%
Response.Expires = -1000 'Makes the browser not cache this page
Response.Buffer = True 'Buffers the content so our Response.Redirect will work

'If called displays the login form elements
'The login hidden field shows this is a login form
Sub ShowLogin
%>
<label>Username</label><br />
<input type="text" id=txtUsername name="txtUsername" /><br />
<label>Password</label><br />
<input type="password" id=txtPassword name="txtPassword" /><br />
<input type="hidden" name="login" value="true" />
<input type="button" value="Login" name="btnLogin" onClick="WithForm();" />
<%
End Sub

'Sub called to check whether or not user credentials are ok
'The logout hidden field shows this is a login form
Sub CheckLogin

dim strUsername
dim strPassword
dim strXMLLoginDetails

strUsername = Request.Form("txtUsername")
strPassword = Request.Form("txtPassword")
strXMLLoginDetails = "<HXML><Username>" & strUsername & "</Username><Password>" & strPassword & "</Password></HXML>"

'Response.Write Server.HTMLEncode(strXMLLoginDetails)
'Response.End

If strUsername <> "" OR strPassword <> "" then

dim objLoginNode
set objLoginDLL = createobject("Logindll.LoginClass")

dim GetLoginResult
GetLoginResult = objLoginDLL.LoginEntry(strXMLLoginDetails)

set objDOM = server.CreateObject("MSXML2.DOMDocument")
objDOM.LoadXML(GetLoginResult)



if objDOM.selectSingleNode("Response/RESULT").Text ="SUCCESS" then
Session("Loggedin")=objDOM.selectSingleNode("Respo nse/LOGIN/MembersName").Text
ShowLogout
Response.Redirect "Guestbook2.asp"
else
Response.Write "<span style=""color:red; padding:3px; background-color:#FEF0E2; border:1px solid red;"">The details you entered are incorrect</span>"
ShowLogin
end if
elseif len(Session("Loggedin"))>0 then
ShowLogout
else
showlogin
end if

End Sub

Sub ShowLogout
Response.Write "You are logged in:" & Session("Loggedin") & ""
%>
<input type="hidden" id=logout name="logout" value="true" />
<input type="submit" value="Log out" id="btnLogout" name="btnLogout" />
<%
End Sub

'Check to see if the login form has been submitted
If Request.Form("login") = "true" Then
'If so check the login details were correct
CheckLogin
'If not login, check to see if it is logout
ElseIf Request.Form("logout") = "true" Then
'Clear the session contents
'If this doesn't work just set them to empty or summat
Session.Contents.RemoveAll
Response.Write("You have been successfully logged out")
ShowLogin
'If username registered show logout
ElseIf len(Session("Loggedin"))>0 then
ShowLogout
'If first time show login
Else
ShowLogin
End If

%>
<!--</form>-->
</div>
Jan 24 '08 #1
1 3300
CroCrew
564 Expert 512MB
Why would someone come back to the login page if they are already logged in?

You might rethink this page and make it… Upon successful login redirect them to another page like a welcome page.

Also what are you using for a database?
Jan 25 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: MichaelR | last post by:
I have an asp.net application using forms authentication. 1. It has a simple login page (login.aspx) that uses FormsAuthentication.RedirectFromLoginPage(. . . ). 2. My application has a logout...
2
by: ad | last post by:
I use Login control's Authenticate event to authenticate use. I find that different users can use the same ID to login in the same time. How can I restrict that the some ID can only login once in...
0
by: ShailShin | last post by:
Hi All, Developing an VB App for Login and logout tracking. In App Form there are two buttons login and logout. When user click on login the loginName, LoginTime and LoginDate get stored in...
2
by: Dan | last post by:
Hi, I use the logon control for logging into the application. When logging and checking the option "remember me next time" and then closing the browser without to press any logout button which...
2
by: André | last post by:
Hi, When clicking on "remember me" when logging, the user asks for not to have to log in next time he visits the site. Now, on one side, i read it is recommended to logout properly (clicking...
3
by: Jennifer.Berube | last post by:
okay...so I got this login script and I edited it all and it seems to run fine...IE it listens to the script as far as permissions go when I place a restriction on a page and when you login it...
1
by: Adrock952 | last post by:
I have a link on my site which obviously says "Login" where users log in. I would like that link to be changed to "Logout" when the user has successfully logged in and the session has been created...
10
by: DavidPr | last post by:
When I logout as one user and log in under a different user, it opens with the last user's information. User 1 - Unsername: Davey Jones User 2 - Unsername: David Smith I log out from Davey...
1
by: 9966652260 | last post by:
hello I am currently doing a project on Administrator Module....where a Administrator has to know at this particular time how many users have logged in...... for which i...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

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.