Logo
  • PHP
    • HipHop / HHVM
    • Modern PHP
    • PHPStorm
    • LAMP
    • Laravel
    • Composer
    • PDO
  • JavaScript
    • node.js
    • AngularJS
  • CSS
    • SASS
    • “CSS4” (CSS level 4)
  • HTML
  • Git
  • LAMP
  • Vagrant
  • UI / UX
  • Architecture of …
  • Off-Topic
With ♥ from Berlin
December 7, 2013
Chris
Login, PHP, Security
Comments Off on How the PHP session garbage collector really works

How the PHP session garbage collector really works

PreviousNext
php

Sessions in PHP are easy to handle, but have a tricky configuration underneath. The common opinion is, that when you close your browser, the session is gone. Actually, it’s a little bit more complicated: Have a look on these 3 lines in your php.ini:

session.gc_maxlifetime = 3600
session.gc_probability = 1
session.gc_divisor = 1000

session.gc_maxlifetime says: 3600 seconds (1 hour) after session initialization, PHP will mark this session as “outdated” and flag it as “ready to delete”. The session still exists after 1 hour! But it’s not deleted. The deletion process of all outdated and ready-to-delete file is called “garbage collection” (process), and it’s triggered – with a specific probability – when another user comes to your page and PHP has to compile something. This probability is calculated by session.gc_probability divided by session.gc_divisor. Yeah, a little bit weird, but the people behind PHP have thought about this, and there are reasons for this behaviour.

Have a look on this excellent answer on StackOverflow to read more about this topic: How do I expire a PHP session after 30 minutes?. So in general it means, that when you close your browser and open it again, and are still logged in, it has to do with PHP’s session gargabe collector process. This might happen quite often on low-traffic sites or while you are developing locally.

 

garbage collectorgcPHPsessionsessionstimeout
Share this
organizing css

Jonathan Snook – CSS is a Mess – How to organize CSS in big projects (54min video talk)

shadow dom

Crossbrowser-safe HTML5 video (IE6+) with a few lines of code and just one .mp4 video file

No time to read the full article ? Get the code directly here on GitHub: panique/html5-video. Publishing a video on

forbes 30 under 30

Need motivation ? Check out these 2 awesome “FORBES 30 under 30” lists (web, UI, games)

The FORBES magazine has just published the new “30 under 30” lists, and they are really really interesting! Lots of

vagrant

How to setup a (or multiple) server/LAMP-stack inside a virtual machine for local development with Vagrant and PuPHPet

You know this: You need a new server, something to develop on, something to test on, something to put your

8 awesome pure CSS spinner / loader

Excllent spinner / loader in pure CSS, made with just one element (even if the demo shows this in a

java

Interesting: code of the same application in PHP, Python, Ruby, Closure, node.js, Java and Go

Definitly worth a look: Adam Bard created a tiny application in 4 different languages (PHP, Python, Ruby, Closure), just to

github-logo-octocat

GitHub buys Easel.io, a code-free full website creator worth a look

GitHub has just aquired Easel.io (which is NOT easel.ly who offer something similar for infographics / powerpoint !), a powerful

Install MINI in 30 seconds inside Ubuntu 14.04 LTS

This is a guideline on how to install MINI – an extremely simple naked PHP application – more or less

php uk conference

Slides & talks from PHP UK Conference 2014

The slides of most of PHP UK CONFERENCE 2014‘s talks are online, very interesting stuff, have a look. And a

html6

Is this the first HTML6 specification?

  I just found this very interesting “project” including an active, but unpopular GitHub repo: http://html6spec.com/ https://github.com/OscarGodson/HTML6 Looks like these

1/4

Categories

Search

php
How to install the mcrypt php extension (to use Laravel 4)
php uk conference
Profiling PHP Applications by Bastian Hofmann (video from PHP UK Conference 2014)
hiphop php
Vote for “Hack” for HipHop/HHMV support (future style PHP) in PHPStorm 8
php
PHP 5.7 gets refactored core, is 10%-30% faster than PHP 5.5! Wow!
java
Interesting: code of the same application in PHP, Python, Ruby, Closure, node.js, Java and Go
js javascript
[video] Netflix JavaScript Talks about ECMAScript 7: The Evolution of JavaScript
october cms
October CMS, built on top of Laravel, is beautiful, clever and on the way to be the new #1 CMS
JavaScript ECMAScript6 – A short video introduction (5min)
Useful basic linux stuff: Show kernel version, distribution name and distribution version on Ubuntu systems
forbes 30 under 30
Need motivation ? Check out these 2 awesome “FORBES 30 under 30” lists (web, UI, games)
MINI, an extremely simple barebone PHP application
shadow dom
Crossbrowser-safe HTML5 video (IE6+) with a few lines of code and just one .mp4 video file
mod-rewrite-ubuntu-14-04-lts
EOL lists of Ubuntu, Debian and CentOS for your server plannings
php
How to setup / install PHP 5.6 on Ubuntu 14.04 LTS
github-logo-octocat
GitHub buys Easel.io, a code-free full website creator worth a look

Tags

apache bash centos composer conference coupon CSS debian fonts framework git GitHub hack HHVM HipHop HTML HTML5 IDE JavaScript JS LAMP laravel linux mod_rewrite MVC MySQL Nginx optimization PHP PHP 5.5 PHP 5.6 phpmyadmin PHPStorm security server SSD Ubuntu UI UX vagrant video virtual machine voucher VPS wordpress
Side-Project: Wordle-Solver:
www.wordle-helper.info

Pages

  • Privacy Policy