Page 1 of 1
How to prevent frame navigation.
Posted: Mon May 18, 2009 3:40 pm
by karozans
Hi everyone. I have a website that uses frames. Using PHP what is the best way to prevent a user from navigating to the subframe directly instead of going through index.htm?
thank
Re: How to prevent frame navigation.
Posted: Mon May 18, 2009 4:05 pm
by tech603
One way you could do this, is to use sessions on the main frame. Once the session has been started and the session variable is set you can have the other frames check that the session variable has a value. So on the main frame you could so something like
Code: Select all
<?php
session_start();
$_SESSION['frameCheck'] = 'mainFrame';
?>
On the other pages you would check for the session but not start one, so this condition can only be true if the main frame is loaded.
Code: Select all
<?php
if(!isset($_SESSION['frameCheck']) && $_SESSION['frameCheck'] != 'mainFrame' ){
header_location('main frame');
}
?>
This in theory should work, this way a session variable for frameCheck would only be valid in the main frame and if they try and navigate away from the main frame to the sub frames it should redirect them.
Hope that helps point you in the right direction.
Re: How to prevent frame navigation.
Posted: Mon May 18, 2009 4:09 pm
by karozans
Yes is sure does. thanks for the help. I was thinking about sessions but I wasn't sure how to implement it.
thanks