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).

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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"];
?>

Link to comment
Share on other sites

<?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"];
?>

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.