SessionHandlerInterface::open

(PHP 5 >= 5.4.0, PHP 7, PHP 8)

SessionHandlerInterface::open โ€” ใ‚ปใƒƒใ‚ทใƒงใƒณใ‚’้–‹ๅง‹ใ™ใ‚‹

่ชฌๆ˜Ž

public function SessionHandlerInterface::open(string $path, string $name): bool

ๆ—ขๅญ˜ใฎใ‚ปใƒƒใ‚ทใƒงใƒณใ‚’ๅ†ๅบฆๅˆๆœŸๅŒ–ใ™ใ‚‹ใ‹ใ€ใ‚ใ‚‹ใ„ใฏๆ–ฐใ—ใ„ใ‚ปใƒƒใ‚ทใƒงใƒณใ‚’ไฝœๆˆใ—ใพใ™ใ€‚ ใ‚ปใƒƒใ‚ทใƒงใƒณใŒ้–‹ๅง‹ใ—ใŸใ‚Š session_start() ใŒๅฎŸ่กŒใ•ใ‚ŒใŸใ‚Šใ—ใŸใจใใซใ‚ณใƒผใƒซใ•ใ‚Œใพใ™ใ€‚

ใƒ‘ใƒฉใƒกใƒผใ‚ฟ

path

ใ‚ปใƒƒใ‚ทใƒงใƒณใ‚’ๆ ผ็ด/ๅ–ๅพ—ใ™ใ‚‹ใƒ‘ใ‚นใ€‚

name

ใ‚ปใƒƒใ‚ทใƒงใƒณๅใ€‚

ๆˆปใ‚Šๅ€ค

่ฟ”ใ‚Šๅ€ค (้€šๅธธใฏใ€true ใŒๆˆๅŠŸใใ—ใฆ false ใŒๅคฑๆ•—ใ‚’่กจใ—ใพใ™)ใ€‚ใ“ใฎๅ€คใฏ PHP ใงๅ†…้ƒจ็š„ใซๅ‡ฆ็†ใ•ใ‚Œใ‚‹ใ‚‚ใฎใงใ‚ใ‚‹ใ“ใจใซๆณจๆ„ใ—ใพใ—ใ‚‡ใ†ใ€‚

ๅ‚่€ƒ

  • session_name() - ็พๅœจใฎใ‚ปใƒƒใ‚ทใƒงใƒณๅใ‚’ๅ–ๅพ—ใพใŸใฏ่จญๅฎšใ™ใ‚‹
  • session.auto-start
๏ผ‹add a note

User Contributed Notes 2 notes

up
6
narf at devilix dot net ยถ
11 years ago
The suggestion that you should free the lock as soon as possible is WRONG (and for some reason, I can't downvote it right now).

Releasing the lock before the write() call is as effective as not using locks at all. The whole point is that a concurrent read() HAS to be blocked until the session is closed, otherwise you'll have race conditions.

If you care about the performance aspect, you should take care to call session_write_close() as soon as possible instead.
up
-3
tony at marston-home dot demon dot co dot uk ยถ
8 years ago
Note that once $sessionName has been used to provide a value for $sessionId from the cookie data it is totally redundant as all further reading and writing of the session data is controlled by $sessionId.

If, for any reason, it becomes necessary to identify the value for $sessionName which is associated with the current $sessionId then you should use the value that was passed on the open() method. Attempting to use a value from an alternative source could have unexpected side effects.