From c2fec5e1bddcd65c773f6093b0d2bb0a51bf55b7 Mon Sep 17 00:00:00 2001 From: Jeroen Versteeg <jversteeg@gmail.com> Date: Mon, 30 Sep 2019 12:53:29 +0200 Subject: [PATCH] Update simplesamlphp-sp.md (#1210) This includes instructions on how to use SimpleSAMLphp with the PHP session backend while you are using it too in your application, also with a custom session handler. --- docs/simplesamlphp-sp.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/simplesamlphp-sp.md b/docs/simplesamlphp-sp.md index 7fc47ee94..f212db95d 100644 --- a/docs/simplesamlphp-sp.md +++ b/docs/simplesamlphp-sp.md @@ -197,6 +197,26 @@ your own session after calling SimpleSAMLphp, you can do so by cleaning up the s If you don't cleanup SimpleSAMLphp's session and try to use $_SESSION afterwards, you won't be using your own session and all your data is likely to get lost or inaccessible. +Note that if your application uses a [custom session handler](https://www.php.net/manual/en/function.session-set-save-handler.php), SimpleSAMLphp will use it as well. This can lead to problems because SimpleSAMLphp's stand-alone web UI uses the default PHP session handlers. Therefore, you may need to unset the custom handler before making any calls to SimpleSAMLphp: + + // use custom save handler + session_set_save_handler($handler); + session_start(); + + // close session and restore default handler + session_write_close(); + session_set_save_handler(new SessionHandler(), true); + + // use SimpleSAML\Session + $session = \SimpleSAML\Session::getSessionFromRequest(); + $session->cleanup(); + session_write_close(); + + // back to custom save handler + session_set_save_handler($handler); + session_start(); + + Support ------- -- GitLab