Cannot send session cache limiter - headers already sent

0 votes

I have been facing a problem with sessions which is becoming very annoying. Every time I try to start a session on a particular page I get the following error:

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at ............ on line 23


using this code:
<?php 
session_start(); 
if(isset($_SESSION['user'])) 
{ 

            $user = $_SESSION['user']; 
            echo "$user"; 
} 
else 
{
  } 
?>

Is it suggesting I've already used session_start(); ? I've had a look around but nothing really clears this up for me. Thank you in advance for the help!!

Feb 18, 2022 in Others by Rahul
• 9,670 points
6,270 views

1 answer to this question.

0 votes
The line "Headers already sent" means that your PHP script already sent the HTTP headers, and as such it can't make modifications to them now. Check that you don't send ANY content before calling session_start. Better yet, just make session_start the first thing you do in your PHP file so put it at the absolute beginning, before all HTML basically.
answered Feb 18, 2022 by Aditya
• 7,680 points

Related Questions In Others

0 votes
1 answer

Error cannot provide both a color and a decoration in Flutter container.

Hi@akhtar, The color and decoration arguments cannot both be supplied, since it ...READ MORE

answered Jul 29, 2020 in Others by MD
• 95,440 points
5,085 views
+1 vote
0 answers

I am not able to see the chat box on webinar-session. i can see only ask question pane

Today (8/aug/2020) I have joined one webinar, ...READ MORE

Aug 9, 2020 in Others by Ravibharathi
• 130 points
1,082 views
0 votes
1 answer

script1.ps1 cannot be loaded because running scripts is disabled on this system.

Hi@akhtar, This error happens due to a security ...READ MORE

answered Sep 8, 2020 in Others by MD
• 95,440 points
1,453 views
0 votes
1 answer

How to add a send button inside TextField in Flutter?

Hi@akhtar, You can use decoration inside your TextField. ...READ MORE

answered Sep 10, 2020 in Others by MD
• 95,440 points
23,752 views
0 votes
0 answers

PHP Unset Session Variable

I am working on creating a product ...READ MORE

Jun 9, 2022 in PHP by Kichu
• 19,050 points
860 views
0 votes
0 answers

Why is PHP session_destroy() not working?

Why is session_destroy() not working? Is there any other way ...READ MORE

Jun 12, 2022 in PHP by narikkadan
• 63,620 points
1,085 views
0 votes
0 answers

What is the difference between Sessions and Cookies in PHP?

What is the distinction between Sessions and Cookies ...READ MORE

Jun 13, 2022 in PHP by narikkadan
• 63,620 points
280 views
0 votes
0 answers

Using sessions & session variables in a PHP Login Script

I have created a login and register ...READ MORE

Jun 17, 2022 in PHP by narikkadan
• 63,620 points
446 views
0 votes
1 answer

How to fix "Headers already sent" error in PHP

The functions that send and modify the ...READ MORE

answered Feb 17, 2022 in Others by Aditya
• 7,680 points
6,650 views
0 votes
1 answer

TCPDF ERROR: Some data has already been output, can't send PDF file

To answer your question, do add the ...READ MORE

answered Feb 16, 2022 in Others by Aditya
• 7,680 points
3,624 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP