tags:

views:

107

answers:

1

Hi All,

I have a page with cfwindow that require the user to be logged in to view the content on the page. The problem at the moment is if the user logs into the site, then does nothing and the session times out, I have no way that I can think of to redirect the parent of the window to the login screen when the user opens it.

So far I have tried using cflocation but that has no way of specifying the container that should be redirected (i.e. the page in the window is being redirected but not the windows parent). I have also thought about using a hidden input with a value based on the session which is then check with Body onLoad event but currently this doesnt work with how the pages have been setup.

The last option I have is to check the session variable on loading the window and then closing it if the user is not logged in, which will cause the parent to refresh and redirect to login anyway. However I cant find a way to close a cfwindow without using javascript.

Thanks for any help you can give.

+3  A: 

What you probably want to do is -- instead of doing a <cflocation/> when you detect that the session is timed out; you want to output HTML content indicating the session has expired, and a JavaScript redirect, something like this:

Your session has expired. Please log in again.
<script type="text/javascript">
    document.location.href = '/login.cfm';
</script>
<cfabort/>

Secondly:

I cant find a way to close a cfwindow without using javascript.

Why is that a problem? CFWindow is created with JavaScript. There are even helper methods to close it:

ColdFusion.Window.hide('{windowNameHere}');
Adam Tuttle
Thanks thats what I was after. In terms of closing the window I was hoping there was a server side method to tell the browser to close the window, but I later realised that I can do this just be running the javascript if a condition was met server side.
Ryan French