You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* 6.0:
ignore the cached body when comparing e-mails for equality
fix PHP syntax to be compatible with 7.2 and 7.3
[HttpFoundation] Add session ID regex comment
[Workflow] Fix typo in MethodMarkingStore
Fix CS
Copy file name to clipboardExpand all lines: Session/Storage/NativeSessionStorage.php
+30Lines changed: 30 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -136,6 +136,36 @@ public function start(): bool
136
136
}
137
137
138
138
$sessionId = $_COOKIE[session_name()] ?? null;
139
+
/*
140
+
* Explanation of the session ID regular expression: `/^[a-zA-Z0-9,-]{22,250}$/`.
141
+
*
142
+
* ---------- Part 1
143
+
*
144
+
* The part `[a-zA-Z0-9,-]` is related to the PHP ini directive `session.sid_bits_per_character` defined as 6.
145
+
* See https://www.php.net/manual/en/session.configuration.php#ini.session.sid-bits-per-character.
146
+
* Allowed values are integers such as:
147
+
* - 4 for range `a-f0-9`
148
+
* - 5 for range `a-v0-9`
149
+
* - 6 for range `a-zA-Z0-9,-`
150
+
*
151
+
* ---------- Part 2
152
+
*
153
+
* The part `{22,250}` is related to the PHP ini directive `session.sid_length`.
154
+
* See https://www.php.net/manual/en/session.configuration.php#ini.session.sid-length.
155
+
* Allowed values are integers between 22 and 256, but we use 250 for the max.
156
+
*
157
+
* Where does the 250 come from?
158
+
* - The length of Windows and Linux filenames is limited to 255 bytes. Then the max must not exceed 255.
159
+
* - The session filename prefix is `sess_`, a 5 bytes string. Then the max must not exceed 255 - 5 = 250.
160
+
*
161
+
* ---------- Conclusion
162
+
*
163
+
* The parts 1 and 2 prevent the warning below:
164
+
* `PHP Warning: SessionHandler::read(): Session ID is too long or contains illegal characters. Only the A-Z, a-z, 0-9, "-", and "," characters are allowed.`
165
+
*
166
+
* The part 2 prevents the warning below:
167
+
* `PHP Warning: SessionHandler::read(): open(filepath, O_RDWR) failed: No such file or directory (2).`
0 commit comments