Jump to content

[SOLVED] find out the time that a session was set?


bobinindia

Recommended Posts

Not to my knowledge. But, you could use an include file to start the session like:

 

<?php
  session_start();
  if(!isset($_SESSION['time_started']))
    $_SESSION['time_started'] = time();
?>

 

Then, at the top of your all your scripts, include that file. After that, you can refer to $_SESSION['time_started'] for the time the session was started

Link to comment
Share on other sites

just define all your session variables like this

 

<?php

function set_session_var ($varname, $value) {
    if ( !isset($_SESSION[$varname]) ) {
        $_SESSION[$varname] = $value;
        $_SESSION['_TIME_STARTED'][$varname] = time();
    } else
        $_SESSION[$varname] = $value;
}

function get_time_set ($varname, $date_format = FALSE) {
    if ( !isset($_SESSION['_TIME_STARTED'][$varname]) )
        return FALSE;

    if ( $date_format )
        return date( $date_format, $_SESSION['_TIME_STARTED'][$varname] );
    else
        return $_SESSION['_TIME_STARTED'][$varname];
}

function get_newest_var_name () {
    if ( !is_array($_SESSION['_TIME_STARTED']) )
        return FALSE;

    $holder = $_SESSION['_TIME_STARTED']
    arsort($holder);
    reset($holder); // May be unnecessary, too lazy to check right now 
    return key($holder);
}

?>

 

Keeps track of their creation date for you

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.