It's very simple. You just have to check weather the user is logged in or not. If logged in you render the page, if not you do not render the page.
==
<p>Welcome, You're logged in to a secure page</p>
<p>Please log in to continue</p>
A Technique: A better way is you can create 3 files.
--
profile.php
--
profile_loggedin.php
--
profile_not_loggedin.php
Then,
<?php
if($user_logged_in == true)
{
require 'profile_loggedin.php';
}
else
{
require 'profile_notloggedin.php';
}
?>
In
profile_loggedin.php
you can write code for the logged in mode of the profile page and in
profile_not_loggedin.php
the not logged in mode of the profile page.