Skip to content

Instantly share code, notes, and snippets.

@phpdave
Last active August 29, 2015 14:24
Show Gist options
  • Select an option

  • Save phpdave/e8bfc5a829dfab982e95 to your computer and use it in GitHub Desktop.

Select an option

Save phpdave/e8bfc5a829dfab982e95 to your computer and use it in GitHub Desktop.
Seperating Session files based on Port #
In the request both cookies are sent over, but PHP only uses the one it was assigned to in the apache config
Cookies sent over after establishing a session on both ports:
PHPSESSID81=njd6d7nv533amuaq4mu5q722t6; PHPSESSID82=eim233h8qmqt8voa0g9nc2jvf6
C:\tmp\81\sess_njd6d7nv533amuaq4mu5q722t6
site|i:81;
C:\tmp\82\sess_eim233h8qmqt8voa0g9nc2jvf6
site|i:82;
<?php
//C:/xampp/htdocs/81/
session_start();
$_SESSION['site']=81;
var_dump($_SESSION); //array (size=1) 'site' => int 81
<?php
//C:/xampp/htdocs/82/
session_start();
$_SESSION['site']=82;
var_dump($_SESSION); //array (size=1) 'site' => int 82
Listen 81
Listen 82
<VirtualHost *:81>
DocumentRoot "C:/xampp/htdocs/81/"
php_value session.save_path "/tmp/81/"
php_value session.name "PHPSESSID81"
</VirtualHost>
<VirtualHost *:82>
DocumentRoot "C:/xampp/htdocs/82/"
php_value session.save_path "/tmp/82/"
php_value session.name "PHPSESSID82"
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment