-2

I'm new to php.. Im trying to get value from session. Below is my code.

Set session in login page

session_start(); 
$_SESSION["username"] = $username ; 
$_SESSION["password"] = $password ; 
$_SESSION["companycode"] = $companycode;

Get the session

if(! isset($_SESSION))
session_start();  
$a=$_SESSION["companycode"];
echo $a;

But i got the warning in my page:

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\lucent\clientlogin.php:216) in C:\xampp\htdocs\lucent\clientlogin.php on line 219

Please help. Thanks

taskinoor
  • 45,586
  • 12
  • 116
  • 142
  • If this is practically the first thing that gets processed, my next question is... do you have PHP errors on? If so, turn them off and try it again. You can at least eliminate that. – Logan Bibby Apr 15 '12 at 04:30
  • 1
    possible duplicate of [Headers already sent by PHP](http://stackoverflow.com/questions/8028957/headers-already-sent-by-php) – Mike B Apr 15 '12 at 04:34
  • 2
    Sorry, but this error comes up about 500 billion times a day on this site. A simple google search would've found you the solution as well. – Marc B Apr 15 '12 at 04:40

3 Answers3

3

You're sending text somewhere before starting the session. Stop doing that.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
1

may be you have white space's before <?php in some file.
check your files

Vahid Chakoshy
  • 1,497
  • 15
  • 27
0

Maybe the problem is the "" that you need to chango to ''

$_SESSION['nome'] == "" in to $_SESSION['nome'] == ''

or

Your file encoding is UTF8 and has blank row and that can cause header to be sent. Change encoding to ANSI.

I use Notepad++ and you can see encoding in the bottom right corner.

If none of the above works try moving it before <html> tag.