Cbenn Cbenn - 26 days ago 5x
PHP Question

*Solved* - PHP sessions security

This question was solved almost instantaneously. Thank you!

I am not sure how to explain this, but basically I want users to navigate to a file called index.php on my apache server installed on the root directory on my site. Whenever they visit this URL, they get a session or cookie, something to tell my server that they visited this site with a timed expiration of 5 minutes. This will redirect them to another site, for example, http://bing.com. Whenever they get redirected to the same index.php on my site, the session will be read and if it is present and hasn't expired, use echo to display an iframe element. If there is no session or it has expired, redirect to http://bing.com.

I have tried this myself, but I am too much of an amateur. Here is my script:

if ((isset($_SESSION["visit"]) {
unset ($_SESSION['visit']);
echo "<p>Success</p><br><iframe src=secretpage.html width=100% height=95% frameBorder=0></iframe>"
else {
header("Location: http://bing.com");

I appreciate your time and effort.

if (isset($_SESSION['visit'])) {
    echo '<p>Success</p><br><iframe src=secretpage.html width=100% height=95% frameBorder=0></iframe>';
} else {
    header('Location: http://bing.com');