Currently what I do is store the user's username after a sucessful login into a session variable.
$_SESSION['session_loggedin'] = $post_username;
post_username is the POST from the submit form.
Then i use this session variable to check if it is set, to see if a user is logged in. I use the value of this variable to show user-specific content.
<?php
if (isset($_SESSION['session_loggedin'])) {
?>
<a href="logout.php">LOGOUT</a>
<?php
}
?>
Is this how sessions are meant to be used? Is this a right way to securely show content? How do I prevent hijacking?
Thanks