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
How to prevent frame navigation.
Moderator: General Moderators
Re: How to prevent frame navigation.
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
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.
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.
Code: Select all
<?php
session_start();
$_SESSION['frameCheck'] = 'mainFrame';
?>
Code: Select all
<?php
if(!isset($_SESSION['frameCheck']) && $_SESSION['frameCheck'] != 'mainFrame' ){
header_location('main frame');
}
?>
Hope that helps point you in the right direction.
Last edited by Benjamin on Mon May 18, 2009 4:08 pm, edited 1 time in total.
Reason: Changed code type from text to php.
Reason: Changed code type from text to php.
Re: How to prevent frame navigation.
Yes is sure does. thanks for the help. I was thinking about sessions but I wasn't sure how to implement it.
thanks
thanks