Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

session_set_save_handler(): Cannot change save handler when headers already sent...


MountainMan

Recommended Posts

Am using a moderately modded Frozen.  Was surprised with a server move to PHP 7.2 from 7.1. 

Now having session errors ??  Not sure what is going on.

I understand that session_start() must be called before outputting anything to the browser.  Perhaps this is what the error is telling me?  If so, how to track 'er down?

Link to comment
Share on other sites

In Phoenix, the line that triggers the session_set_save_handler call is in application_top.php at

  require 'includes/functions/sessions.php';

It seems to be claiming that output is being sent before that line.  One possibility to find what is causing it is to keep moving that line higher in the file until it either works or you get a different error.  Sometimes that helps if that line is not dependent on other code having run first.  Could not be moved prior to the includes/configure.php line.  Not sure about other dependencies. 

It does seem like PHP 7.2 became stricter in its session handling.  So something that was always broken may now be announcing that it is broken.  Compare what you have above that line and in files included before that to what Frozen has to see what may have changed. 

It's also worth noting that this can happen if you have a different error or warning displayed before the session started.  You can fix that by turning off display_errors.  E.g. at the top of includes/application_top.php put

ini_set('display_errors', 0);

Put it right before the starting time is set, after the previous comment is closed.  That may shift things from totally broken to just moderately broken.  If that is what the problem is.  So this error would go away and you could concentrate on the other problems that would still be there. 

Always back up before making changes.

Link to comment
Share on other sites

Headers WERE already sent, because I found a couple spaces at the beginning of a file, before the  "<?php".  Was it there all along and the upgrade to PHP 7.2 caught it..., well, just not smart enough to answer that question, and I gots to keep movin... Panic over.  Site back up.

Found it by creating a test page based on application_top.  Stripped the contents from app_top to bare bones required for sessions, added some basic html at the bottom so it would function as a page, and poked and prodded until I found the offending file.

It helped that while searching for answers I had read via our now questionable friend Google* that PHP was indeed becoming picky about added spaces at the beginning of a file.

Appreciate everyone's help.

*I say this because Google's search results appear to now heavily favor their paid advertisers.  I remember pre-Google, at the beginning of this thing called the Internet, when there were the first initial attempts at search engines.  Google caught on fast because their results at the time were trusted to be based on "relevance" whereas some of the other search engines back then were tinkering with taking money to be ranked higher.   That's for you youngsters.  Here's another one.  Did you know professionals - doctors and lawyers - were not allowed to advertise... and look what you have now on TV, billboards, etc.  Dont think it is an improvement.  Thank God for my DVR.

Link to comment
Share on other sites

  • 1 month later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...