Mohawk Software Session Handler Functions
msession is an interface to a high speed session daemon which can run either locally or remotely. It is designed to provide consistent session management for a PHP web farm. More Information about msession and the session server software itself can be found at » http://www.mohawksoft.org/?q=node/8.
This extension is not available on Windows platforms.
This extension has been moved to the » PECL repository and is no longer bundled with PHP as of PHP 5.1.3.
To enable Msession support configure PHP
Table of Contents
Code Examples / Notes » ref.msession
a dot whyte
You can fix the no random data in FreeBSD's /dev/random by using rndcontrol (as root) and setting the interupts which it looks at for entropy.
Something like rndcontrol -s 14 -s 15 should help it out.
We've created a distributed session handler that uses memcached - Check it out at http://weirdsilence.net/software/memsession/ - It's free and open source!
It uses Danga.com's memcached: http://danga.com/memcached/ - Very cool stuff!
We wanted to use the default-PHP4-RPMs delivered with RedHat and SuSE, and use msession, too. But there is no package containing the precompiled msession-support for PHP. So I did this on my own and I found it very hard, so I'd like to provide the solution here.
The files php-msession-030117.tar.gz, phoenix-R1_2_030117E.tar.gz and msession-030130.tar.gz are
available at www.mohawksoft.com.
## Compiling the phoenix lib
tar xzf phoenix-R1_2_030117E.tar.gz
tar xzf msession-030130.tar.gz
cp Linux.mak config.mak
(Now change "-I$(POSTGRES_HOME)/include" to "-I /usr/include/pgsql" which is needed to compile using SuSE 9.3)
## Compiling msession server
## Now untar PHP-Source and replace the files in ext/msession/ with the ones supplied by php-msession-030117.tar.gz
## Configure PHP and include --with-msession=shared,/path/to/phoenix-src-used-above
## Please note: Compile will fail if you use --disable-session or --disable-all
## For example use:
./configure --prefix=/usr/local --with-config-file-path=/etc --disable-all --enable-session --with-msession=shared,/home/sga/compile/phoenix
## Now there is a msession.so in modules/, but this one does NOT work yet.
## I had to repeat the libtool-command with "--mode=link gcc" and add some libs:
## before the last parameter I added:
## -lstdc++ -lodbc -L/home/sga/compile/phoenix/lib/ -lphoenix
## This was the command I used (you will have to use other paths of course)
/bin/sh /home/sga/compile/php-4.3.10/libtool --silent --preserve-dup-deps --mode=link gcc -DPHP_ATOM_INC -I/home/sga/compile/php-4.3.10/include -I/home/sga/compile/php-4.3.10/main -I/home/sga/compile/php-4.3.10 -I/home/sga/compile/php-4.3.10/Zend -I/home/sga/compile/php-4.3.10/ext/xml/expat -I/home/sga/compile/php-4.3.10/TSRM -g -O2 -o ext/msession/msession.la -export-dynamic -avoid-version -prefer-pic -module -rpath /home/sga/compile/php-4.3.10/modules -lstdc++ -lodbc -L/home/sga/compile/phoenix/lib/ -lphoenix ext/msession/msession.lo
## Now I could do:
cp ext/msession/.libs/msession.so /usr/local/lib/php/extensions/no-debug-non-zts-20020429
## (Please note the different location I copy the module from)
## Adjust your php.ini to contain "extension=msession.so" and
## "extension_path =/usr/local/lib/php/extensions/no-debug-non-zts-20020429"
## Now it worked fine! I hope this helps someone.
Trying to build PHP 5.0.4. with msession support (shared), I found that the build process still fails to link the proper libraries. I think the proper way to fix this, is to change ext/msession/config.m4 and rebuild configure.
Find the line that reads:
PHP_ADD_LIBRARY_WITH_PATH(phoenix, "$PHOENIX_DIR/lib", PHOENIX_LIB)
And replace it with these two lines:
PHP_ADD_LIBRARY_WITH_PATH(phoenix, "$PHOENIX_DIR/lib", MSESSION_SHARED_LIBADD)
PHP_ADD_LIBRARY_WITH_PATH(stdc++, "", MSESSION_SHARED_LIBADD)
Next find the line that reads:
and replace it with:
Now rebuild "configure":
$ rm configure
$ ./buildconf --force
Now ./configure && make && make install as usual.
To compile with --with-msession, you have to make a change in Makefile to add -lstdc++. For me the LDFLAGS=-lstdc++ before ./configure don't work.
That modification works for me:
sed -e 's/^\(EXTRA_LIBS\)\(.*\)$/\1\2 -lstdc++/g' Makefile -i
I think that have some better way to do it.
msession 1.0 (020603) is using /dev/urandom.
If you have trouble connecting to the msessiond from a php-script, this might be the solution for you.
msessiond (and your php-extension) both use the libphoenix.a which, among other files, is built from a file called "mutils.cpp".
Open this file, and find a line saying:
FILE *f = fopen("/dev/random", "rb");
(I believe it is line 506. There's only this one.)
On my FreeBSD 4.5 Tiny, /dev/random seldom spits out data, so the program hangs on the next line (an fread() call). Use /dev/urandom instead, it always sends data.
Change the line above to:
FILE *f = fopen("/dev/urandom", "rb");
Then rebuild phoenix-lib, msessiond, and PHP. You might want to do a "make clean" to be sure the change is noted.
I went through and installed mcache and took notes about problems I ran in to. I couldn't get it to work in 64 bit CentOS but it works in 32 bit CentOS. If anybody got it working in 64 bit or wants to see what I have done, please feel free to visit my blog (i didn't want to spam post all the things here). Here is the blog: http://crazytoon.com/mcache
I could not compile it on FreeBSD. On a 4.x msession complained about missing pthread library. On a 5.x, it was not happy with malloc.h. Ok, I could dig into that problem and find the problem. But I was not motivated...
I found that there is 1 100% PHP Solution for distributed session handling:
Hi all, I'm the author of the msession daemon. I haven't done any actual work on it in a couple years. Suddenly, I find myself needing it again. It's current state is almost certainly VERY different than you are used too, and it as been renamed to mcache (internally to Mohawk Software). I may ramp up work on it again.
In the course of the 5 years that msession being made available, I've gotten a lot of calls for support, and one bug fix. (And not a single donation BTW)
A decisions needs to be made if "mcache" will continue to be available. I don't mind people using it, I don't mind that I've made no money on it (that's not why I wrote it), but the desperate "my server farm is down" calls because a working system died when the admin deployed changes with out adaquite testing are a huge distraction. In good conscience, I can't let the poor guy twist in the wind, but sometimes it takes hours to fix. Hours away from work that pays my bills or my family. Apache 2.0 with multiple threads really caused a lot of problems.
So, I guess what I'm saying is this: msession will become mcache (publically) some time in the future. On modern hardware it can handle about 5,000 ~10,000 session transactions a second (depending on the amount of data in the session, and the conectivity to the nodes, etc.) I may keep it on my server, but I can't support it for you without being paid up front. If you use it: learn it, know it, live it, and contribute if you can.
Has been renamed to Mcache, improved, and is available at http://www.mohawksoft.org/
Compiling msession can be quite a pain. Believe me.
Here's how I did it on a gentoo-box with gcc version 3.3.4 (20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6)):
1. Download http://www.mohawksoft.com/devel/phoenix-R1_2_030117E.tar.gz and http://www.mohawksoft.com/devel/msession-030130.tar.gz
2. Extract them in /usr/local (That path is hardcoded, so you don't really have a choice since there isn't a configure script)
3. You should now the directory /usr/local/phoenix containing msession and src.
4. Enter the src-directory and rename Linux.mak to config.mak (or the corresponding file, if you're using another system. Don't use unixgcc.mak directly - it won't work.).
5. Type make
6. Type make install. You might have to create /usr/local/phoenix/lib yourself and then type make install again.
7. Change into the msession-directory and type make.
For both msession and phoenix you may have to edit the makefiles manually and comment out the postgreesql and odbc-code (if you don't have postgree installed).
8. Recompile php with --with-msession.
A company I work for uses msession for a large cluster of servers. I've set it up rather regularly and never had an issue at all with it not working.
Msession is stable. It does something simple- it maintains an efficient database of key->value (session->data) pairs and searches them well in a nice threaded manner. There is no need for constant revision. It is _NOT_ a large application. It's security is simply IP-block-based, so such concerns are also minimal.
To the user that says it should be removed- if you are having problems installing it, seek assistance doing so. The product itself is just right.
Alternative PHP Cache
Advanced PHP debugger
Aspell functions [deprecated]
BCMath Arbitrary Precision Mathematics Functions
PHP bytecode Compiler
Bzip2 Compression Functions
CCVS API Functions [deprecated]
ClibPDF Functions [deprecated]
COM and .Net (Windows)
Character Type Functions
Cybercash Payment Functions
Credit Mutuel CyberMUT functions
Cyrus IMAP administration Functions
Date and Time Functions
Database (dbm-style) Abstraction Layer Functions
DBM Functions [deprecated]
Direct IO Functions
DOM XML Functions
Error Handling and Logging Functions
File Alteration Monitor Functions
Forms Data Format Functions
Firebird/Interbase Functions (PDO_FIREBIRD)
Function Handling Functions
Haru PDF Functions
Hyperwave API Functions
IBM Functions (PDO_IBM)
IIS Administration Functions
Imagick Image Library
Informix Functions (PDO_INFORMIX)
Ingres II Functions
IRC Gateway Functions
PHP / Java Integration
Lotus Notes Functions
MaxDB PHP Extension
Mcrypt Encryption Functions
MCVE (Monetra) Payment Functions
Ming functions for Flash
Microsoft SQL Server Functions
Microsoft SQL Server and Sybase Functions (PDO_DBLIB)
Mohawk Software Session Handler Functions
Multibyte String Functions
MySQL Functions (PDO_MYSQL)
MySQL Improved Extension
Ncurses Terminal Screen Control Functions
Object Aggregation/Composition Functions
Object property and method call overloading
ODBC Functions (Unified)
ODBC and DB2 Functions (PDO_ODBC)
OpenAL Audio Bindings
Oracle Functions [deprecated]
Oracle Functions (PDO_OCI)
Output Control Functions
Ovrimos SQL Functions
Paradox File Access
Process Control Functions
Regular Expression Functions (Perl-Compatible)
Phar archive stream and classes
Regular Expression Functions (POSIX Extended)
PostgreSQL Functions (PDO_PGSQL)
Program Execution Functions
PostScript document creation
GNU Recode Functions
RPM Header Reading Functions
SAM - Simple Asynchronous Messaging
Satellite CORBA client extension [deprecated]
SDO XML Data Access Service Functions
SDO Relational Data Access Service Functions
SESAM Database Functions
PostgreSQL Session Save Handler
Session Handling Functions
Shared Memory Functions
Standard PHP Library (SPL) Functions
SQLite Functions (PDO_SQLITE)
Secure Shell2 Functions
Shockwave Flash Functions
TCP Wrappers Functions
Variable Handling Functions
Verisign Payflow Pro Functions
XML Parser Functions
Zip File Functions
Zlib Compression Functions