Trixbox, PHP Sessions and FOP2

All the popular Asterisk distributions, like Trixbox, Elastix, PBX in a Flash, etc, include a basic LAMP stack (Linux, Apache, Mysql and PHP).

In order for the phonebook and some extra FOP2 features to work, PHP sessions must be working. By default, the standard PHP configurations will store a cookie on your browser with the session id, so you also must allow cookies to be written.

Trixbox includes a LAMP stack, but in its latest release also includes a PHP module to store sessions in memory using memcached. That is really nice and dandy, unfortunately, they forgot to enable the memcached daemon in the boot process. So, in a standard trixbox installation, PHP sessions are broken.

Everything will appear to be working fine, except when you try to open the FOP2 phonebook or any other section that requires php sessions enabled. You will see an error like:

"No way"

(unpolite message from FOP2 versions 2.20 or older)

or

"You do not have permissions to access this resource"

In order to fix this, you have two options:

1) Start the memcache daemon and enable it at boot

2) Disable the memcache module and use the standard file based php sessions

As I have seen the memcached based sessions failing for no apparent reason, my suggestion is to disable the memcache module. For doing that, you can edit the file /etc/php.d/memcache.ini and comment out ALL lines in that file:

; Enable memcache extension module
;extension=memcache.so

; Options for the memcache module

; Whether to transparently failover to other servers on errors
;memcache.allow_failover=1
; Defines how many servers to try when setting and getting data.
;memcache.max_failover_attempts=20
; Data will be transferred in chunks of this size
;memcache.chunk_size=8192
; The default TCP port number to use when connecting to the memcached server
;memcache.default_port=11211
; Hash function {crc32, fnv}
;memcache.hash_function=crc32
; Hash strategy {standard, consistent}
;memcache.hash_strategy=standard

; Options to use the memcache session handler

; Use memcache as a session handler
;session.save_handler=memcache
; Defines a comma separated of server urls to use for session storage
;session.save_path="tcp://localhost:11211?persistent=1&weight=1&timeout=1&retry_interval=15"
After that, restart your web server:
service httpd restart
After that , you should have file based php sessions working on your Trixbox setup.

2 Responses to Trixbox, PHP Sessions and FOP2

  1. 7 Mark Tishenko 2011-09-29 10:45 pm

    Nicolas,

    Good post. This fixed my issue with the phonebook and recordings.

    Thanks.

    Mark Tishenko

  2. 25 Elijah Lynn 2012-02-09 1:55 pm

    This is helpful, I want to add that I had to also "service httpd restart" followed by a "service fop2 restart" before I got it working, it was still quirky when I got it working because Firefox wouldn't work, I even deleted all local session cookies and wiped them in /var/lib/php/session and no go. Either way, this morning when I came in Firefox worked fine.

    Thanks for this article. It led me in the right direction.

Leave a Reply