0

I have develop my site that required login. If user not yet login it will redirected to login page. But i have problem after i click login, here is problem:

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at ......../corporateuser/request.php:1) in ........../corporateuser/request.php on line 2

Here is the code:

1. <?php
2. session_start();
3. if(!isset($_SESSION['login'])){
4.  header("Location:login.php");
5.  exit();
6. }
7. include_once("action.php");
8. ?>

What is the problem with that warning, line 1 and 2?

Mark
  • 8,046
  • 15
  • 48
  • 78
Sovat
  • 59
  • 1
  • 8

1 Answers1

0

You have to put session_start(); on the top of your php page. is this the top?

for example:

<html>
<head>
//stuff
</head>
<body>
//beginning of page:
<?php session_start();
//rest of code.
?>
</body>
</html>

otherwise:

<?php

if(!isset($_SESSION['login'])){
session_start();
header("Location:login.php");
exit();
}
include_once("action.php");
?>

NOTE: this probably fixes your first error. (Line 1)

Kees Sonnema
  • 5,759
  • 6
  • 51
  • 106