Simple PHP session_start() problems

Asked by:
HubFans / n/a Points
Time:
2015-04-06 1:25 pm EST
Category:
Website Troubleshooting
Hits:
2,203
I have been trying to get a php CMS working on my website. I know there are other applications i could use, but i really want to do one on my own. I had everything working on my localhost (im using xampp for my localhost) and when i finally uploaded the whole code, it started showing 2 errors: one session_start cannot send session cookie and another Cannot send session cache limiter.

I have tried to look around the web for a solution and everything points me to the fact that i have some hidden character before my session_start() which is making output, so i decided to make the simplest php possible with session_start:

<?php
// Start the session
session_start();
?>
<!DOCTYPE html>
<html>
<body>

<?php
// Set session variables
$_SESSION["favcolor"] = "green";
$_SESSION["favanimal"] = "cat";
echo "Session variables are set.";
?>
</body>
</html>

But even with this im still getting this as output:

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /public_html/Apps/CMSAttempt/cms/index.php:1) in /public_html/Apps/CMSAttempt/cms/index.php on line 3

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /public_html/Apps/CMSAttempt/cms/index.php:1) in /public_html/Apps/CMSAttempt/cms/index.php on line 3
Session variables are set.

I am somewhat new to PHP and i am trying to do this as a learning project, but at the moment im completly lost. It works on my localhost, but not on webhosting and i ran out of ideas.

Can anyone help me? Thanks!

To ask this user for more information, please first login.

To submit an answer, please login.

ANSWERS

0

arnelc
Staff
17,314 Points
2015-04-06 6:43 pm EST
Hello,

Sorry to hear that you're having problems with the sessions. Typically, coding support is beyond the scope of technical support (especially custom work). I did have a systems person look at your code and the results though. He mentioned that your error indicates that something is already setting the session BEFORE your code. You may need to look what is loading up as soon as you try to open your site. Double-check what is loading through the Apache web server on the hosting service as opposed to your offline installation as a place to start. Apologies again that we can't give you a direct answer in regards to the issue.

Kindest regards,
Arnel C.

To submit a comment on this answer, please first login.

Want to share this Question?

Related Articles

It looks like there are no related articles.
Would you like to ask a question about this page? If so, click the button below!
Need More Help?

Help Center Search

Current Customers

Email: support@WebHostingHub.com Ticket: Submit a Support Ticket
Call: 757-416-6627 Chat: Click To Chat Now

Ask the Community

Get help with your questions from our community of like-minded hosting users and Web Hosting Hub Staff.

Not a Customer?

Get web hosting from a company that is here to help.
}