I recall reading somewhere recently that you can obtain the server session start-time in timestamp format of the exact time a php session started for a user, but I cannot find this article again.
What I do not want is the request time (ie the time the 'REQUEST_TIME'
) or the "current timestamp" as of the execution of date()
because (if I understand these correctly) they will change for each request and each script execution.
What I want is the time that the session was initiated on the server, and this logically can only be one moment in time.
There was apparently a was of retrieving this information.
Can anyone help?
You can start a session in PHP by using the session_start() function. This function will, by default, first check for an existing session. If a session already exists, it will do nothing, but it will create one if there's no pre-existing session available.
Start a PHP Session A session is started with the session_start() function. Session variables are set with the PHP global variable: $_SESSION.
Note: The session_start() function must be the very first thing in your document. Before any HTML tags. As for your question you can start session wherever you want, but beware that session must be started before any output.
what's wrong with:
if (!isset($_SESSION['started'])) {
$_SESSION['started'] = $_SERVER['REQUEST_TIME'];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With