• Home
  • Archives
  • Super Lamb Bananas
Subscribe: Posts | Comments | E-mail
  • Coding
  • Events
  • Gaming
  • Media
  • Myself
  • Photos
  • Places
  • School
  • Technology

Jordan Hatch’s Blog

Posted on September 23, 2007 - by Jordan H

PHP Session Purging

Coding

I’ve been trying to make a login script that purges the sessions database so that users will only stay inactive for 1 hour until they have to log in again. All seems to be well, but then it just doesn’t work.

This is the code which I have on every page:

$time = date("ymdHis");
$cutoff = $time-1000;

$sql = "DELETE FROM adminsessions WHERE time<'$cutoff'";
mysql_query($sql) or die(mysql_error());

It should log the user out after 10 mins of inactivity. Doesn’t seem to be doing that at the moment. Anyone got any ideas?

This entry was posted on Sunday, September 23rd, 2007 at 2:11 pm and is filed under Coding. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

4 Comments

Feel free to post yours!



  1. Visit My Website

    January 18, 2008

    Permalink

    Charlie said:

    Hi Jordan,

    What field type is the ‘time’ field?

    Try $sql = “DELETE FROM adminsessions WHERE time<$cutoff”; too (without the quotes around $cutoff)

    Regards,

    Charlie



  2. Visit My Website

    January 18, 2008

    Permalink

    Jordan H said:

    I fixed it using that way ages ago. :D But thanks for the call!



  3. Visit My Website

    January 18, 2008

    Permalink

    Charlie said:

    Thought it was a bit old to comment on, but I was a tad bored! (6)



  4. Visit My Website

    July 5, 2008

    Permalink

    Damo said:

    Field type must be float, int or bigint for size operators like > and < to work, and also for ordering with ORDER BY to work.

    –damo



Leave a Comment

Here's your chance to speak.

  1. Name (required)

    Mail (required)

    Website

    Message

  • Flickr Photos

  • Latest Tweets

    • Blogroll

      • Alexander Ward
      • Charlie Hothersall
      • Damien Walsh
      • Josh Semans
      • Karan Bhangui
      • Mike Tomasello
    • Find Me Online!

      • Brightkite
      • Flickr
      • Twitter
    • Archives

      • October 2008
      • September 2008
      • August 2008
      • July 2008
      • June 2008
      • May 2008
      • April 2008
      • March 2008
      • February 2008
      • January 2008
      • December 2007
      • November 2007
      • October 2007
      • September 2007
    • Tag Cloud

      • acegx blackpool blog burnout content database dlc flickr games geekup inactive iphone jhsystems lg liverpool login manchester modules newcastle perl php ps3 reviews script sessions single site sitemail smarty summer superlambanana system t-mobile television template theme twitter user users website wordcamp wordpress xbox 360 xewsletter x factor
    Copyright © 2006-8 Jordan Hatch
    Powered by WordPress