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

How Instagram.com works

increase-your-pagespeed-score

Increase your PageSpeed score (10min video with Matt Gaunt)

Compact and clever information for dramatic speed increases. Definitly worth watching.

php

Postmodern PHP: appserver.io, a multithreaded application server for PHP, written in PHP

There’s a lot of very interesting stuff going on in the PHP scene right now, I have the feeling this

sass laravel

Extremely easy SASS in Laravel (with pure PHP)

Working with SASS is awesome: it reduces your workload dramatically, makes web projects much cleaner, DRYs your code, adds awesome

photoshop-cc-deal

Adobe offers Photoshop for $9.99 per month (limited deal)

Currently Adobe offers the very latest version of Photoshop (which is Photoshop CC) for just $9.99 or 12,99€ (EU zone:

the-php-login-project

How to install php-login-one-file on Ubuntu 12.04 LTS

This tutorial will show you how to install the one-file version of php-login.net‘s login script (see the full GitHub repository

phpstorm-github-code-color-syntax-theme

Get Github’s syntax highlighting colors in PHPStorm

I really really like the colors on GitHub’s code previews but couldn’t find any themes that copy that in a

sass

New features in SASS 3.3 (a talk by SASS-creator Chris Eppstein)

A very interesting conference talk by Chris Eppstein, creator of SASS itself, showing some of the new features in SASS

[Link] Redesigning SoundCloud by Evan Simoni

Again, an interesting approach / proof-of-concept on a redesign of a major website. Evan Simoni has overthought SoundCloud’s UI and

java vs php

Switching from Java to PHP. Seriously. A very interesting and pre-judice-free talk with Ph.D. Aris Zakinthinos

Ph.D. Aris Zakinthinos, CTO of achievers.com, a well-scalability-experienced guy and former IT employee of the military, has just delivered one

1/4

Categories

Search

How to setup a config-free WordPress, PHP and MySQL (for local development) in Windows 7 / 8 in under 3 minutes
How to hack time (KUNG FURY promo campaign)
phpstorm 7.0 php
How to debug code on a remote server (or in vagrant box) with PHPStorm
Increase your HTML / CSS coding speed with EMMET
php
12 tools for better PHP quality
Interesting stats on SONY’s hacked passwords
js javascript
How JavaScript really works – An introduction into the JavaScript call stack by Philip Roberts (20min video)
This is an experimental advertisement
phpstorm-github-code-color-syntax-theme
Get Github’s code colors in PHPStorm (2014 style)
twig
A 6min video introduction into Twig, the PHP templating engine
How to install/setup latest version of PHPMyAdmin on Ubuntu 12.04 LTS (Precise Pangolin)
times-new-roman
The Times talks about Times New Roman (3min video)
Compare 250+ cloud server plans with Cloud Cost Calculator
Frontend Ops Conf 2014 – Rebooting Flickr On A Node.js Stack, One Page At A Time (from PHP) by Bertrand Fan
laracon-2014-eu-amsterdam
Laracon 2013 – Jordi Boggiano: In Depth Composer (47min video)

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