Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help on logout

Status
Not open for further replies.

ryan1982

Technical User
Jan 20, 2002
38
SG
i've had a problem with logout using asp
which i think with javascript might help

situation:

i used a field in the database called "logon" with "yes/no" variable

everytime the user logs in the variable is changed to
login = true

and everytime the user logs out the varible is changed
to login = false

but if the user clicks on the X(top right) in internet
explorer and does not logout,
the login variable remains as true and he/she is not able to login again

i've read a function called window.close but i had probs
using this function ..

i need some help on functions which will be called when the
user click on the X(top right) button in IE
so i can automatically log them out.

i'm just a beginner using asp so pls dun give some
complicated functions or coding , i may not understand them
:)
thanks in advance
 
Hi,

Think out side the box -

Use the windows.close javascript command to get them to log out by producing an alert saying something like:

"You have not logged out, please press the "logout" button first before closing your browser"

Then, they will have to log out otherwise the alert box will keep popping up.

Of course, once there logged out, do a page without the alert script in.

Do u need the script?

James
 
thanks james
i really need the script urgently

i have probs using windows.close

i tried doing an example like this:

<script language = javascript>

if window.close() {

window.alert &quot;hi&quot;

}

</script>


in one of my asp page but when i click on the X(close)
button in one asp page with the javascript function above it doesnt prompt me with a message box &quot;HI&quot;

can u just type in the script here?
or if its too long u can sent it to me
at
ryan1982@hardwarezone.com

thanks
 
Hi,

Just suddenley realised in the mist of Mac OS server problems that window.close only works if u close the window from the page, not on the X button, but there are other ways around it.

A) Do you use cookies or be prepared to use them?
B) Is it for IE only? (and then Version 5.0 and higher?)
C) You could use the unload command, but that will make it occur on every single page load u do.
D) Would u mind a popup? If not, then you can create a popup window when u first do the site, which sits in the background and can be your logout button if they forget, then u can use the unload command.

Sorry, Mac Os is messing my head around today!

James
 
A)i do not intend to use any cookies on my site
B) im using it for IE 5 and higher
and its better if it can be used for netscape
but it doesnt matter cos i just want it to be able to
work right now :)
C) i've read abit abt the unload command but i've no idea
how to use it
D) i do not mind a pop-up at all as long as my logout works

james have u done any unload command before?
if you have can u gimme an example?
or do u have any script with unload?

i need to finish this function urgently cos the
deadline for this function is tomolo :(

hope to hear from u soon :)
 
Ryan,

Ok mate here are your options:

A) Unload Command - Used in your body tag, everytime the page unloads, e.g. refreshs, closes, goes to another page, the alert occurs.

Code is:
In head Tag
Code:
function Error()
{
alert(&quot;Please log out of your browser before closing it. Thankyou&quot;)
}
In Html
Code:
,<Body onUnload=&quot;Error()&quot;;>

B) Cromeless Window
This opens up a window which is cromeless, it has nothing, no title bar, no status bar, not even the little X box to close it.

Go here how to use it


Quick and simple way of doing it, then u can make the close button also your log out button

C) Popup
Produce a simple a popup when you enter your site, which includes the onUnload command as well as a Logout button on it.

Thats it

I would go with B if your doing only IE, or C if your doing anything else.

Hope this helps

James
 
thanks james
i finish the logout function
i've had probs using cromeless windows
so i just used a pop-up window

anyway thanks for your help :)
i appreciated that
 
Hi,

No worries.

That chromelss script is a right piglet to get to work

James
 
i've had a problem with my login and logout asp. I want to protect my web pages with password, but sometime the script still not secure. I still can open another pages without login.

The other problem is logout script. What I must do with the logout script ? is it using session.timeout or session.abandon ???

I really need a help for this problem. Because I already search over the internet and mostly to complicated for me, because i can't programming in this problem.

Best Regards.
praz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top