I have faced an issue when I uploaded my source code to a hosting.
In my HTML/PHP pages, I have some code like the following one:
<!DOCTYPE html>
<html lang="es">
<?php
session_start();
....
....
?>
If I run the page in my localhost, with display_errors=On … I do not get any error for the session, but if I run in the hosting (with same PHP version), I get this error:
Warning: session_start(): Session cannot be started after headers have already been sent in
This error doesn’t allow me to get $_SESSION variable, so I can’t continue.
I’m trying to replicate in my local environment, but I can’t configure the server to behave in the same way.
I have identified how to solve it (moving <!DOC….> after the session_start() command), but I would like to understand how to replicate this issue in my environment.
Is there any PHP.ini or Apache configuration that I’m missing in my local environment?
Thanks in advance.
I tried to change parameters in PHP.ini but I was not able to replicate the behaviour of the hosting environment.
Firmo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
How can I determine what is the mechanism which causes session_start to create new sessions wrather than resume a previous one?
john smith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.