This is what has to be done. If the user is comming to the site from an outside url, then they get an alert message and then are redirected.
The problem is that for some reason this seems to loop. The alert keeps popping up again and again. This code seems to work if the url in window.location.href is one directory up. Why?
For instance:
I have it like this now: window.location.href = "page.cfm" and it seems to loop like this (the alert keeps popping up again and again)
If I put the page.html in an directory above, like this: window.location.href = "../page.cfm" it works fine.
Why?? Any ideas??
The code we're using:
I have not failed; I merely found 100,000 different ways of not succeding...
The problem is that for some reason this seems to loop. The alert keeps popping up again and again. This code seems to work if the url in window.location.href is one directory up. Why?
For instance:
I have it like this now: window.location.href = "page.cfm" and it seems to loop like this (the alert keeps popping up again and again)
If I put the page.html in an directory above, like this: window.location.href = "../page.cfm" it works fine.
Why?? Any ideas??
The code we're using:
Code:
<CFAPPLICATION NAME="MyApplication" SESSIONMANAGEMENT="Yes" SESSIONTIMEOUT="#CreateTimeSpan(0,0,45,0)# APPLICATIONTIMEOUT=#CreateTimeSpan(0,0,45,0)#">
<CFPARM NAME = "session.LoggedIn" DEFAULT = "FALSE">
<!-- If the user is not logged in, not currently on the login page, 4gotten the password -->
<CFIF #session.LoggedIn IS "FALSE">
<CFIF (CGI.SCRIPT_NAME IS NOT "file.cfm")
AND (CGI.SCRIPT_NAME IS NOT "file_name.cfm")
AND (CGI.SCRIPT_NAME IS NOT "file_name2.cfm")
<script>
alert("you are being redirected");
window.location.href = "login.cfm";
</script>
</CFIF></CFIF>