Jump to content

[SOLVED] Session id help


phpcode

Recommended Posts

Either use cookies or reset a session on every pageload checking for difference in unixtime.

 

<?php

if(!$_SESSION['last_active))
{
    $_SESSION['last_active'] = date("U");
}
else
{
    if( (date("U") - 60) > $_SESSION['last_active'] ) 
        {
            $_SESSION['valid_user'] = 0;
        }
}
?>

 

Really generic. Try to use cookies. 60 seconds is also kinda short. Guess it depends on your goal. (I didn't test the above code, that's off the top of my head, check for logic/syntax).

Either use cookies or reset a session on every pageload checking for difference in unixtime.

 

<?php

if(!$_SESSION['last_active))
{
    $_SESSION['last_active'] = date("U");
}
else
{
    if( (date("U") - 60) > $_SESSION['last_active'] ) 
        {
            $_SESSION['valid_user'] = 0;
        }
}
?>

 

Really generic. Try to use cookies. 60 seconds is also kinda short. Guess it depends on your goal. (I didn't test the above code, that's off the top of my head, check for logic/syntax).

 

Doesn't work.

Either use cookies or reset a session on every pageload checking for difference in unixtime.

 

<?php

if(!$_SESSION['last_active']))
{
    $_SESSION['last_active'] = date("U");
}
else
{
    if( (date("U") - 60) > $_SESSION['last_active'] ) 
        {
            $_SESSION['valid_user'] = 0;
        }
}
?>

 

Really generic. Try to use cookies. 60 seconds is also kinda short. Guess it depends on your goal. (I didn't test the above code, that's off the top of my head, check for logic/syntax).

 

Doesn't work.

 

Yeah, there's a typo in it :) As said, it's not tested. YMMV. Play a little bit, you'll figure it out.

I saw the typo this is what I did to it:

 

<?php

if(!$_SESSION['last_active'])
{
   $_SESSION['last_active'] = date("U");
}
else
{
   if( (date("U") - 60) > $_SESSION['last_active'] )
       {
           $_SESSION['valid_user'] = 0;
       }
}

echo $_COOKIE["PHPSESSID"];
?>

<?php session_start(); //<<< this was missing hay

if(!$_SESSION['last_active'])
{
   $_SESSION['last_active'] = date("U");
}
else
{
   if( (date("U") - 60) > $_SESSION['last_active'] )
       {
           $_SESSION['valid_user'] = 0;
       }
}

echo $_COOKIE["PHPSESSID"];
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.