# SAML: Headers Already Sent Error

**URL:** <https://community.xibo.org.uk/t/saml-headers-already-sent-error/15747>\
**Category:** Get Help\
**Created:** [September 13, 2018, 4:20pm UTC](https://community.xibo.org.uk/t/saml-headers-already-sent-error/15747 "2018-09-13T16:20:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ian\_M](https://community.xibo.org.uk/user_avatar/community.xibo.org.uk/ian_m/32/12699_2.png) [@Ian\_M](https://community.xibo.org.uk/u/Ian_M)\
**Post date:** [September 13, 2018, 4:20pm UTC](https://community.xibo.org.uk/t/saml-headers-already-sent-error/15747/1 "2018-09-13T16:20:42Z")

</div>

Hi All,  
We’ve just upgraded to 1.8.11, and moved to PHP 7. Now SAML Authentication isn’t working. The SAMLResponse comes in OK, but the application crashes when trying to generate a new session for the authenticated user, with the error `'session_regenerate_id(): Cannot regenerate session id - headers already sent`

The stack trace is:

```
#0 [internal function]: Slim\Slim::handleErrors(2, ''session_regener...'', ''F:\<Our Site>...'', 289, Array)
#1 F:\<Our Site>\lib\Helper\Session.php(289): session_regenerate_id(true)
#2 F:\<Our Site>\lib\Middleware\SAMLAuthentication.php(298): Xibo\Helper\Session->regenerateSessionId()
#3 [internal function]: Xibo\Middleware\SAMLAuthentication->Xibo\Middleware\{closure}()
#4 F:\<Our Site>\vendor\slim\slim\Slim\Route.php(468): call_user_func_array(Object(Closure), Array)
#5 F:\<Our Site>\vendor\slim\slim\Slim\Slim.php(1355): Slim\Route->dispatch()
#6 F:\<Our Site>\vendor\slim\slim\Slim\Middleware\Flash.php(85): Slim\Slim->call()
#7 F:\<Our Site>\vendor\slim\slim\Slim\Middleware\MethodOverride.php(92): Slim\Middleware\Flash->call()
#8 F:\<Our Site>\lib\Middleware\Actions.php(160): Slim\Middleware\MethodOverride->call()
#9 F:\<Our Site>\lib\Middleware\Theme.php(36): Xibo\Middleware\Actions->call()
#10 F:\<Our Site>\lib\Middleware\SAMLAuthentication.php(414): Xibo\Middleware\Theme->call()
#11 F:\<Our Site>\lib\Middleware\CsrfGuard.php(63): Xibo\Middleware\SAMLAuthentication->call()
#12 F:\<Our Site>\lib\Middleware\State.php(122): Xibo\Middleware\CsrfGuard->call()
#13 F:\<Our Site>\lib\Middleware\Storage.php(47): Xibo\Middleware\State->call()
#14 F:\<Our Site>\lib\Middleware\Xmr.php(37): Xibo\Middleware\Storage->call()
#15 F:\<Our Site>\vendor\slim\slim\Slim\Slim.php(1300): Xibo\Middleware\Xmr->call()
#16 F:\<Our Site>\web\index.php(124): Slim\Slim->run()
#17 {main}'

```

Because this didn’t happen with PHP 5.x I suspect it’s something that’s changed in 7. Has anybody encountered this and found what to do about it? We’re running on IIS.

edit: In php\_errors.log, there is a little more information: `headers already sent in \web\xmds.php on line 254` I’m not clear how xmds.php is getting in the way of authentication, though.

---

<div class="post-metadata">

**Author:** ![Peter](https://community.xibo.org.uk/user_avatar/community.xibo.org.uk/peter/32/8154_2.png) [@Peter](https://community.xibo.org.uk/u/Peter)\
**Post date:** [September 18, 2018, 1:50pm UTC](https://community.xibo.org.uk/t/saml-headers-already-sent-error/15747/2 "2018-09-18T13:50:05Z")

</div>

Could you please confirm for me what exactly PHP version do you have installed now?

Just to also test something, if you’d clear sessions and browser cache, access the CMS in incognito mode, do you get the same error?

---

<div class="post-metadata">

**Author:** ![Ian\_M](https://community.xibo.org.uk/user_avatar/community.xibo.org.uk/ian_m/32/12699_2.png) [@Ian\_M](https://community.xibo.org.uk/u/Ian_M)\
**Post date:** [September 18, 2018, 7:07pm UTC](https://community.xibo.org.uk/t/saml-headers-already-sent-error/15747/3 "2018-09-18T19:07:36Z")

</div>

Peter,  
Thanks for your response. We’re on 7.1.13, to be precise.

Unfortunately, it happens with incognito mode, different browser, different computer, etc.

---

<div class="post-metadata">

**Author:** ![Ian\_M](https://community.xibo.org.uk/user_avatar/community.xibo.org.uk/ian_m/32/12699_2.png) [@Ian\_M](https://community.xibo.org.uk/u/Ian_M)\
**Post date:** [October 31, 2018, 5:53pm UTC](https://community.xibo.org.uk/t/saml-headers-already-sent-error/15747/4 "2018-10-31T17:53:48Z")

</div>

For anybody who runs into something similar:

So the issue turned out to be that the directory `\temp_files\php_session.save_path` was misplaced after the PHP upgrade, causing it to lose track of sessions. Putting this directory at a place in the filesystem that matched the one specified by php7.ini did the trick.

---

<div class="post-metadata">

**Author:** ![system](https://community.xibo.org.uk/uploads/default/original/2X/a/a8759c2d8cc561474733895ac75beeb830f5d8ca.png) [@system](https://community.xibo.org.uk/u/system)\
**Post date:** [March 4, 2020, 5:12pm UTC](https://community.xibo.org.uk/t/saml-headers-already-sent-error/15747/5 "2020-03-04T17:12:09Z")

</div>

Closed on March 4, 2020, 5:12pm UTC


