CakeFest 2024: The Official CakePHP Conference

SessionUpdateTimestampHandlerInterface::updateTimestamp

(PHP 7, PHP 8)

SessionUpdateTimestampHandlerInterface::updateTimestampタイムスタンプを更新する

説明

public SessionUpdateTimestampHandlerInterface::updateTimestamp(string $id, string $data): bool

セッションが最後に変更されたタイムスタンプを更新します。 この関数はセッションが更新された場合に自動的に実行されます。

パラメータ

id

セッションID

data

セッションデータ

戻り値

タイムスタンプが更新されたら true を、 そうでなければ false を返します。 この値は、PHP が処理を行うために内部的に返す値であることに注意して下さい。

add a note

User Contributed Notes 3 notes

up
4
tuncdan dot ozdemir dot peng at gmail dot com
1 year ago
I am not sure why the data is needed for this method if it only updated the timestamp only. Otherwise wouldn't his be the same the 'write' method? I think it is confusing and the manual unfortunately doesn't give much information about the whole session mechanics.
up
5
ohcc at 163 dot com
3 years ago
When session.lazy_write is enabled, which is the default behaviour, session data will NOT be UPDATED if it remains unchanged, in this way the WRITE method of the session handler will not be called at all.

If your session handler storages session data into files, UpdateTimestamp is used to update the "last modified time" of the session file, if your session handler storages session data into a database, UpdateTimestamp is used to update the table field that storages the last modified time of the session registry.
up
2
ohcc at 163 dot com
4 years ago
'validateId' is called after 'open' and before 'read' to validate the session id provided by the client, as 'open' -> 'validateId' -> 'read' -> 'write' -> 'close' are called in sequence.

If 'validateId' returns false, a new session id will be generated, the session cookie will also be updated afterwards.
To Top