@@ -231,4 +231,31 @@ public function testRegenerateSessionIdWriteWithoutClose(): void
231231 $ this ->assertSame ($ newData , $ handler2 ->read ($ newSessionId ));
232232 $ this ->assertTrue ($ handler2 ->close ());
233233 }
234+
235+ public function testReadDifferentSessionIdsWithoutCloseReleasesPreviousLock (): void
236+ {
237+ $ handler = $ this ->getInstance ();
238+ $ handler ->open ($ this ->sessionSavePath , $ this ->sessionName );
239+
240+ $ firstSessionId = $ this ->generateSessionId ('bbbbbb ' );
241+ $ secondSessionId = $ this ->generateSessionId ('cccccc ' );
242+
243+ $ firstData = '__ci_last_regenerate|i:1664607454;user|s:5:"alice"; ' ;
244+ $ this ->assertSame ('' , $ handler ->read ($ firstSessionId ));
245+ $ this ->assertTrue ($ handler ->write ($ firstSessionId , $ firstData ));
246+ $ this ->assertTrue ($ handler ->close ());
247+
248+ // Read two different session IDs on the same handler without closing between them
249+ $ this ->assertTrue ($ handler ->open ($ this ->sessionSavePath , $ this ->sessionName ));
250+ $ this ->assertSame ($ firstData , $ handler ->read ($ firstSessionId ));
251+ $ this ->assertSame ('' , $ handler ->read ($ secondSessionId ));
252+
253+ // Another handler should be able to acquire the lock for the first session ID
254+ $ handler2 = $ this ->getInstance ();
255+ $ this ->assertTrue ($ handler2 ->open ($ this ->sessionSavePath , $ this ->sessionName ));
256+ $ this ->assertSame ($ firstData , $ handler2 ->read ($ firstSessionId ));
257+ $ this ->assertTrue ($ handler2 ->close ());
258+
259+ $ this ->assertTrue ($ handler ->close ());
260+ }
234261}
0 commit comments