Joy
(@joyously)
When I do a search for “PHP 7,2 and session”, I get a bunch of results of people with the same problem. Sounds like it’s not WordPress, which does not use sessions.
It sounds like you may be calling session_start() after page output has started. You can’t do that. It’s just like sending headers or setting cookies has to be done before any output. Not sure why it worked before. I don’t even know if this is the problem, I’m just guessing. Failure could be for any number of problems, cookie failure, failure to pass ID, file system issues, etc.
Setup a couple simple test pages outside of WP. If these don’t work either, there is some fundamental system failure. If they work, take a hard look at your WP implementation, you’re probably doing something wrong that was formerly tolerated but now fails. Poor coding practice is a common cause of failures after upgrades.
Thread Starter
cbonwp
(@cbonwp)
thanks for the replies, definitely not calling session_start after any page output. I’ve just re-instated the old wordpress version and the problem is there too. So suspect is host upgrade to php 7.2.
Got this message in log file
[22-Nov-2018 10:57:42 UTC] PHP Deprecated: __autoload() is deprecated, use spl_autoload_register() instead in /customers/e/8/7/saliannefrenchfocus.com/httpd.www/wordpress/wp-includes/compat.php on line 502
Will investigate later
thanks again
Thread Starter
cbonwp
(@cbonwp)
ok, this autoload change is fixed in wordpress 4.9.8
just original problem of session_start failing so no access to previously stored session variables
Hi @cbonwp, you can do your session as following way but keep in mind, if you would like to do anything within your theme pages, then do it in your header.php file before loading any output to the browser, so better if you do it before <html> tag in php so there will be no output before storing any session.
if(session_id() == '')
session_start();
Thread Starter
cbonwp
(@cbonwp)
hi Umar, i have an init hook on page loads so put a session_start in there – now it all works again! There’s still a session_start within each page but it doesn’t seem to matter – maybe it’s just ignored.
Don’t quite see at the moment why this glitch appeared.
thanks, clive