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

Hacked french TV channel exposed passwords in TV interview (video, screenshots, links)

This week a major french TV networks was hacked (Article on CNN #1, #2), resulting in 11 channels being completely

JavaScript ECMAScript6 – A short video introduction (5min)

Excellent introduction into the new ECMAScript6, the spec behind JavaScript.

php

PHP 5.6.0 RC1 is available

The first Release Candidate of PHP 5.6 is available here on php.net, as usual also for Windows systems. The RC

php

Test out PHP 5.6alpha1 on Windows 7 / 8 with two clicks

The popular Apache-MySQLP-PHP stack EasyPHP has become very professional, maintained and especially modularized in the last 2 years, and when

hack-php

Wow! Facebook devs have rewritten and fixed PHP, releasing it as new language called “Hack” today

Exciting stuff is happening: Some years ago Facebook has released an early preview of HipHop, a virtual machine that precompiles

php

How to install/setup latest version of PHP 5.5 on Debian Wheezy 7.0/7.1/7.2 (and how to fix the GPG key error)

Please note: This works fine. But this package will also upgrade your apache to version 2.4 which has different config

How to install/setup latest version of PHPMyAdmin on Ubuntu 12.04 LTS (Precise Pangolin)

As the official installation packages of most linux distributions are usually totally out of date (but that’s pure intention, to

phpstorm 7.0 php

How to setup and use XDEBUG with PHPStorm 6/7 (locally in Windows 7/8 and Mac OS X)

Real debugging is probably one of the most coolest things that are possible in software development: Remember the times where

php uk conference

PHP Caching Best Practices by Eli White (video from PHP UK Conference 2014)

The title says it all: PHP Caching best practices.

composer

A short & simple Composer tutorial

In this little Composer tutorial we’ll walk through the absolute basics of Composer, the PHP dependency management tool. Composer has

1/4

Categories

Search

[Link] Interesting: Designing a Nuclear Waste Warning Symbol That Will Still Make Sense in 10,000 Years
Google I/O 2014 – HTTPS Everywhere (video)
phpstorm-8
PHPStorm 8 (early access version) released – for free
phpstorm-8
When PHPStorm’s cache eats up your harddisk space
phpstorm 7.0 php
How to setup and use XDEBUG with PHPStorm 6/7 (locally in Windows 7/8 and Mac OS X)
ubuntu-14-04-lts lamp
How to install/setup a basic LAMP stack (Linux, Apache, MySQL, PHP) on Ubuntu 14.04 LTS
Symfony devs: Creator of Symfony framework is hiring (Cologne, Germany)!
What’s new in PHPStorm 9
Support FLARUM, the future of PHP forum scripts (with some dollars on Kickstarter)
vagrant
A preinstalled Vagrant box with PHP HipHop / HHVM and Ubuntu 12.04 (Precise Pangolin)
vagrant
How to setup a local server (in a virtual machine) with Vagrant in PHPStorm
php
12 tools for better PHP quality
Redesigning Windows 8 – fantastic and clever drafts by Jay Machalani
php
How to prevent PHP sessions being shared between different apache vhosts / different applications
logo-internet-explorer
How to professionally test on old Internet Explorer versions

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