PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.18.0
GiveWP – Donation Plugin and Fundraising Platform v4.18.0
4.18.0 4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 All 257 releases
give / vendor / vendor-prefixed / symfony / http-foundation / Session / SessionUtils.php

SessionUtils.php in GiveWP – Donation Plugin and Fundraising Platform 4.18.0, at vendor/vendor-prefixed/symfony/http-foundation/Session/SessionUtils.php

60 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <[email protected]>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Give\Vendors\Symfony\Component\HttpFoundation\Session;
13
14 /**
15 * Session utility functions.
16 *
17 * @author Nicolas Grekas <[email protected]>
18 * @author Rémon van de Kamp <[email protected]>
19 *
20 * @internal
21 */
22 final class SessionUtils
23 {
24 /**
25 * Finds the session header amongst the headers that are to be sent, removes it, and returns
26 * it so the caller can process it further.
27 */
28 public static function popSessionCookie(string $sessionName, string $sessionId): ?string
29 {
30 $sessionCookie = null;
31 $sessionCookiePrefix = sprintf(' %s=', urlencode($sessionName));
32 $sessionCookieWithId = sprintf('%s%s;', $sessionCookiePrefix, urlencode($sessionId));
33 $otherCookies = [];
34 foreach (headers_list() as $h) {
35 if (0 !== stripos($h, 'Set-Cookie:')) {
36 continue;
37 }
38 if (11 === strpos($h, $sessionCookiePrefix, 11)) {
39 $sessionCookie = $h;
40
41 if (11 !== strpos($h, $sessionCookieWithId, 11)) {
42 $otherCookies[] = $h;
43 }
44 } else {
45 $otherCookies[] = $h;
46 }
47 }
48 if (null === $sessionCookie) {
49 return null;
50 }
51
52 header_remove('Set-Cookie');
53 foreach ($otherCookies as $h) {
54 header($h, false);
55 }
56
57 return $sessionCookie;
58 }
59 }
60