473,386 Members | 1,766 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,386 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 3303
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.