Error migrating from localhost to online server [duplicate]

2

When migrating an application in codeigniter from localhost to the server it appears me the following error

  

PHP Error was encountered Severity: Warning Message:   session_start (): Can not 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

    
asked by anonymous 01.12.2015 / 21:12

1 answer

1

This error occurs because you are logging in after you have submitted data to the browser.

When defining 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 can not request the beginning of the session.

As a workaround, 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 in .htaccess if you are running an Apache server. This rule makes the session start automatically, without having to use session_start ()

    
01.12.2015 / 23:05