ColdFusion TIPS PLUS
Issue 00099 http://www.cftipsplus.com
I. My Comments
II. ColdFusion In Context: Logout Persuasion
By R. Martin Ladner
martin.ladner@knology.net
See our sponsors at the bottom of this e-mail.
I. Comments:
Job Looking:
If you were laid off and still have not found a job send me your contact email and city and state. Also tell me if you willing to move or not. No promises but I will see what I can do.
I will not send your information to the Employers. I will send you the Employers information.
Employee Looking:
If you have a ColdFusion Job and need someone to fill it please send in your requirements and I will forward the information to anyone who is looking for a job.
Keep Coding,
Nathan Stanford
http://www.cftipsplus.com
If you have suggestions for articles send them to us.
If you would like to write for cftipsplus.com
send us an email to:
admin@cftipsplus.com
IF YOU WANT TO BE AN AUTHOR SEND IN YOUR COLDFUSION TIPS.
Remember this is a great way to get your name known in the
ColdFusion Community.
II. ColdFusion in Context: Logout Persuasion
By R. Martin Ladner
martin.ladner@knology.net
Suppose you want the user to actually log out so you'll know it's OK to release variables in memory prior to their scheduled timeout. Users tend to simply close the window when they're done, and you won't know when they've done that.
One way to handle this problem is to create a parent window whose function is to open a child window for working and be available to nag the user into logging out if the user closes the work window directly.
Create the Context
Here is where the browser will go after logout; call it homepage.cfm.
Welcome to the login page.
<form>
<input type="button" name="doit"
value="Press to simulate log in"?
onClick="javascript:window.location='nag.cfm';">
</form>
Here is where you would add code to remove the session from memory; call it bye.cfm.
You've passed through a page (bye.cfm)<br>
that would remove your session variables from memory.<br>
<script language="javascript">
window.location = 'homepage.cfm';
</script>
Here is where the user will "work"; call it work.cfm. It gives the user a button that will shift the focus to the nag page that invites the user to log out.
Here's your work page. When you're tired of admiring it,<br>
click "Done" (or find nag.cfm).
<form>
<input type="button" name="leave" value="Done"
onClick="opener.window.focus();">
</form>
Do the Work
Pretending that login was successful and that the user has selected a work area, this code needs to open the work area, prime this page so it will check the focus the NEXT time the user touches it, and (if the user asks to log out) close the work area, call a page that would remove the session from the server if you were doing this for real, and deposit the user at the home page. Put all of the following code in nag.cfm.
First, prepare to open the work area. openchild1 names a new window "myChild1" when it creates it so we can use the name later to close it. Note that the features parameter that contains attributes such as toolbar and location (URL window) cannot have any spaces within it.
<head>
<script language="javascript">
function openchild1(mypage) {
myChild1 = window.open('work.cfm','myWindow',
'toolbar=yes,location=yes,scrollbars=yes,resizable=yes');
}
Next, prepare to close the window when asked.
function leave() {
if (!myChild1.closed) {
myChild1.close();
}
window.location = 'bye.cfm';
}
Finally, close the script tag and set the body to open the work window when the page has finished loading and to try to close it when the user logs out.
</script>
</head>
<body onLoad="openchild1('work.cfm');">
<form>
<input type="button" name="doit"
value="~~~ L O G O U T ~~~" onClick="javascript:leave()">
</body>
Try It Out
Browse homepage.cfm and press the button. The work page should appear. If you click "Done", nag.cfm will come forward, asking the user to log out. If you simply close work.cfm, nag.cfm will still be there as a reminder. If you go directly to nag.cfm and log out, it will close work.cfm if it isn't already closed. You wouldn't normally notice bye.cfm, but in this demonstration, it has visible text as a reminder that it's there.
Expand the concept and make it nicer, but be sure you can use your method for major versions of both major browsers. [grim grin] Then, please tell us what you've learned so we can build on higher ground.
=Marty=
SPONSOR ADS:
This e-mail is sponsored by the following ads.
Sponsored Ad
Advanced, Intensive ColdFusion Training!
Visit this site. If you have plans to get training here is a company
that provides Advanced, Intensive ColdFusion Training. Check them out.
http://www.coldfusiontraining.com/index.cfm?ref=cftipsplus
IT'S A WEB DEVELOPER'S DREAM COME TRUE
The book on Aestiva's web-based development engine
is here. Build web-based text editiors in ten lines
or less. Build shopping carts with a couple dozen
lines of code. Build database-driven apps in about
the time it takes you to do your laundry! Get the
book ADVANCED WEB SITES MADE EASY. For more info
please visit:
http://dev.aestiva.com/amazon/htmlostips.html
Sponsored Ad
Looking for other development resources?
Visit
http://www.htmlostips.com, a site dedicated
to HTML/OS, a the next generation development
environment that many are saying is the next
generation to Java.
Sponsored Ad
Publisher and Creator:
Nathan Stanford,
admin@cftipsplus.com
http://www.cftipsplus.com
Macromedia and ColdFusion are U.S. registered trademarks.
Copyright (c) 2000 - 2002 C.F. Concepts, Inc.
CFTIPSPLUS.COM and NSND.COM
Permission is granted to circulate this publication via
MANUAL forwarding by email to friends provided that the text is
forwarded in its entirety and no fee is charged.