session_name breaks my site?

2019-06-27 20:19发布

问题:

After reading through the PHP manual, I added session_name('mysite'); to my code to ensure that collisions between sessions won't happen if I will run multiple apps in the future.

Unfortunately the session_name()-function call it kills my site completely . A fatal error is thrown (which appears in the error logs, but doesn't say anything!) and the below error is shown in the browser:

I have PHP-FPM running along with suhosin+nginx at a freshly installed Ubuntu VM. What am I doing wrong?

回答1:

As pointed out in the comments on the session_name doc page, there are some issues w/ session_name that can cause your site to break:

  1. Make sure that you call session_name before anything else, including session_start
  2. Make sure there are no periods in your session name (i.e.: don't use "mysite.com" as your session name)