Normally I don't ask for time-sensitive help on my blog, but since my readers are such gracious bunch I thought I could count on them to help me out.
I have a site for work that uses frames. Oh yeah, it's CakePHP application. Frames are not my favourite thing in the world, but they are part of this particular site. Now here is my problem:
- Users must be authenticated to use the site, and when they log in from the front page a bunch of frames are loaded. Then they can click around doing stuff.
- When their session times out, meaning they need to get logged back in, I need for the frames to disappear and send them back to front page of the site.
So far, I have not been able to figure out how to do this. I've been told by reliable sources on Twitter that I probably need some Javascript code that does something like this:
-
<script type="text/javascript">
-
if (top !== self) top.location.replace(self.location.href);
-
</script>
but I cannot determine *where* to put that code. Please help this frames n00b figure it out!
Tags: frames, javascript

You'll probably get better comments, but this is a really good article http://bit.ly/TFC8t
Put it in your users/login view. Either exactly as you have it or use $javascript->codeBlock() if you want it to appear in the head tag.
I suggest you to put that on every layout that gets called through frame so no matter what frame gets refreshed it redirects user to the login page if session is expired
I agree with Matt - when a session has expired then the user will be redirected to the login view but within the particular frame that they made the request from, so you might have login view rendered anywhere (sidebar / header / main bit) - therefore whenever the login view is rendered it needs to check its not in a frame and if it is redirect quick.
(Frames, God its been a while...)