File: cleardiscochoices.php

package info (click to toggle)
simplesamlphp 1.19.7-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 42,920 kB
  • sloc: php: 202,044; javascript: 14,867; xml: 2,700; sh: 225; perl: 82; makefile: 70; python: 5
file content (35 lines) | stat: -rw-r--r-- 1,173 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php

require_once('_include.php');

/**
 * This page clears the user's IdP discovery choices.
 */

// The base path for cookies. This should be the installation directory for SimpleSAMLphp.
$config = \SimpleSAML\Configuration::getInstance();
$cookiePath = $config->getBasePath();

// We delete all cookies which starts with 'idpdisco_'
foreach ($_COOKIE as $cookieName => $value) {
    if (substr($cookieName, 0, 9) !== 'idpdisco_') {
        // Not a idpdisco cookie.
        continue;
    }

    /* Delete the cookie. We delete it once without the secure flag and once with the secure flag. This
     * ensures that the cookie will be deleted in any case.
     */
    \SimpleSAML\Utils\HTTP::setCookie($cookieName, null, ['path' => $cookiePath, 'httponly' => false], false);
}

// Find where we should go now.
if (array_key_exists('ReturnTo', $_REQUEST)) {
    $returnTo = \SimpleSAML\Utils\HTTP::checkURLAllowed($_REQUEST['ReturnTo']);
} else {
    // Return to the front page if no other destination is given. This is the same as the base cookie path.
    $returnTo = $cookiePath;
}

// Redirect to destination.
\SimpleSAML\Utils\HTTP::redirectTrustedURL($returnTo);