I have below code to save the session and i redirect to another file where session values are lost.
Index.php
<?php
session_start();
if (isset($_REQUEST['action'])) {
if(!empty($_REQUEST['user'])) $pd_user = $_REQUEST['user'];
$_SESSION['USER_CLIENT'] = 'admin';
$_SESSION['NAME_CLIENT'] = $pd_user;
header("location:view.php");
}
?>
<!DOCTYPE html>
<html>
<body>
<form action="index.php?action=submit" method="post">
<fieldset style="border: medium none;">
<dl>
<dt><label for="email">Username:</label></dt>
<dd><input type="text" name="user" id="user" size="54" /></dd>
</dl>
<dl>
<dt><label for="password">Password:</label></dt>
<dd><input type="password" name="password" id="password" size="54" /></dd>
</dl>
<dl class="submit">
<input type="submit" name="login" id="login" value=" " />
</dl>
</fieldset>
</form>
</body>
</html>
I also get following warning from above code:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/demolink/public_html/feeManagement/index1.php:1) in /home/demolink/public_html/feeManagement/index1.php on line 2
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/demolink/public_html/feeManagement/index1.php:1) in /home/demolink/public_html/feeManagement/index1.php on line 2
view.php
<?php
session_start();
echo 'session array';
print_r($_SESSION);
?>
Please let me know what is wrong in above code?