I got the answer for my question ....
Here is the code for the redirecting user based on the session[user] in LoginViewController.php and it's working fine..
1) Always place session_start() top of the code...
<?php
session_start();
include('GenericClasses/GenericCollectionClass.php');
include('Models/UsersModel.php');
include('DataObjects/Users.php');
include('DatabaseAccess/DBHandler.php');
if(!empty($_SESSION['user']))
{
header("Location:loggedin.php");
die();
}
else
{
?>
//Html code for login page
<?php
}
?>
Here is Loggedin.php code ..
<?php
session_start();
header("Cache-Control: private, must-revalidate, max-age=0");
header("Pragma: no-cache");
header("Expires: Fri, 4 Jun 2010 12:00:00 GMT");
include('GenericClasses/GenericCollectionClass.php');
include('Models/UsersModel.php');
include('DataObjects/Users.php');
include('DatabaseAccess/DBHandler.php');
if(!isset($_SESSION['user']))
{
header('Location: LoginViewController.php');
exit();
}
echo '"<div style="background:white; text-align:right"> Login as:'.$_SESSION['user'].'
<a href="LogoutViewController.php" style="text-align:right">Logout</a></div>"';
?>