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
August 30, 2013
Chris
Linux, PHP
Comments Off on How to prevent PHP sessions being shared between different apache vhosts / different applications

How to prevent PHP sessions being shared between different apache vhosts / different applications

PreviousNext
php

When you run multiple applications on one server, you might run into the session-sharing problem: All your applications share the same pool of PHP sessions. This is especially bad when running multiple instances of the same software, like multiple WordPress blogs etc.

Usually, when running multiple applications, you’ll do this with multiple VirtualHosts on your server (i cannot go into detail what a VirtualHost is or how to setup, as you probably already know when reading such an article). The way to go is simple: Set a different PHP session folder for every VirtualHost, like this:

php_value session.save_path "/var/mysessionsforapplication_1"

 

In this example I’m running two instances of the same application on one server, each one on a different port (you might want to use a domain name here).

<VirtualHost *:81>
    ...
    DocumentRoot /var/www/app1
    <Directory "/var/www/app1">
        AllowOverride All
        php_value session.save_path "/var/mysessionsforapplication_1"
   </Directory>
</VirtualHost>

<VirtualHost *:82>
    ...
    DocumentRoot /var/www/app2
    <Directory "/var/www/app2">
        AllowOverride All
        php_value session.save_path "/var/mysessionsforapplication_2"
   </Directory>
</VirtualHost>

Please note that you need to restart the apache after you’ve changed things like that. Setting up VirtualHosts is a topic on it’s own, so it’s not covered here. In most cases editing

/etc/apache2/sites-available/default

will do the job.

 

Share this
js javascript

JavaScript Testing Tactics (21min video by Justin Searls)

atomic-design

An introduction into Atomic Design, a super-clean way to style web applications

A super-interesting talk of Brad Frost at beyond tellerrand 2013, explaining the basics of Atomic Design: What is Atomic Design

First look on Gitter, the chat for GitHub

GitHub has definitly become the #1 platform for git-based public repositories on the planet, no question. The site offers excellent

Support FLARUM, the future of PHP forum scripts (with some dollars on Kickstarter)

PHP forum scripts are horrible, let’s face it. Nearly everything that’s available is hard to install, hard to handle, hard

How to setup a config-free WordPress, PHP and MySQL (for local development) in Windows 7 / 8 in under 3 minutes

If you need to setup WordPress for local development and don’t have time and nerve to go through the installation

What’s new in PHPStorm 10 (Official promo video)

PHPStorm 10 is out! New features are mainly full PHP7 support, much better auto-recognation / autocompletion (even within arrays (unsure

phpstorm-8

A PHPStorm shortcuts cheat sheet (for Windows, Mac OS and Linux)

Shortcuts that will make you life so much easier! Please note: Frontend Devs might be irritated by the weird CTRL-Y-shortcut,

Hacking ATMs – A conference talk about the current security state of Windows XP driven cash machines

A few days ago the 30th edition of Germany’s Chaos Communication Congress took place, a high-profile event for IT-security and

vagrant

A super-simple Vagrant LAMP stack bootstrap (installable with one command)

As I have to setup servers inside Vagrant quite often, sometimes 10 times per day, I started to use provisioning:

symfony-framework-logo

SensioLabs, creator of Symfony and Silex PHP frameworks, gets $7 million capital

The company behind the two popular PHP frameworks Symfony and Silex just raised 7 million dollars to “expand their open-source

1/4

Categories

Search

github-logo-octocat
GitHub buys Easel.io, a code-free full website creator worth a look
O’Reilly’s Learning JavaScript Design Patterns by Addy Osmani for free
git-php-deployment
Extremely simple deployment with PHPloy
Dangerous Performance Myths in the Web (video talk by Thomas Lohner, PHPUG Latvia)
[Link] Interesting: Designing a Nuclear Waste Warning Symbol That Will Still Make Sense in 10,000 Years
hiphop php
Vote for “Hack” for HipHop/HHMV support (future style PHP) in PHPStorm 8
The architecture of StackOverflow
composer
How to install Composer on Windows 7 / 8 or Ubuntu
redaktionelle-hochlastseiten
Hochlastseiten mit PHP, MySQL und Apache am Beispiel stern.de (deutscher Artikel)
hack-php
Facebook releases HipHop (HHVM) 3.0, adds mysqli and support for Hack language
october cms
October CMS, built on top of Laravel, is beautiful, clever and on the way to be the new #1 CMS
times-new-roman
The Times talks about Times New Roman (3min video)
All new features of WordPress 3.9 in this 2 minute video
vagrant
How to setup a local server (in a virtual machine) with Vagrant in PHPStorm
ubuntu-14-04-lts lamp
How to install/setup a basic LAMP stack (Linux, Apache, MySQL, PHP) on Ubuntu 14.04 LTS

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