Error when migrating from localhost to online server

Asked

Viewed 129 times

2

When migrating a codeigniter application from localhost to the server the following error appears to me

A PHP Error was encountered Severity: Warning Message: session_start(): Cannot send Session cookie - headers already sent by (output Started at /home/bassgrou/public_html/centro_eventos/application/config/mimes.php:1) Filename: Session/Session.php Line Number: 140

Backtrace:

File: /home/bassgrou/public_html/centro_eventos/application/controllers/Cliente_controller.php Line: 7 Function: __Construct

File: /home/bassgrou/public_html/centro_eventos/index.php Line: 292 Function: require_once

  • Normally I have never used session_start() to start aglum thing in CI, you are using?

  • I have autoload from the library 'Session'

  • Use session_start(); preferably as your file’s first function, and never after you have printed or display HTML content.

  • 1

    Solved, it was a blank space before the <?php tag opened in the mime.php file

  • Good afternoon, do not put answers within the question, we are not a forum or anything like that, we are a Q&A, read the tour: http://answall.com/tour. your question was duplicated because in the other answers of the other question you already have the solution to your problem. I’m sure you’ll take this as a constructive criticism.

1 answer

1

This error occurs because you are signing in after you have already sent data to the browser.

When setting a Session you are creating a cookie on the client machine with the session id via HTTP header, so if you have already sent data to the browser, the header has already been closed and sent, so you cannot request the start of Session.

As a solution you can put session_start right at the beginning of your code, or set the Session.auto_start directive in php.ini to true or no. htaccess if you are running on an Apache server. This rule automatically starts the session without using session_start()

Browser other questions tagged

You are not signed in. Login or sign up in order to post.