PHP HybridAuth library without using PHP session

531 Views Asked by At

The PHP HybridAuth require the use of PHP session, however, we want to avoid using server side session since we are running the app on multiple machine.

We don't mind if user need to authenticate with provider every-time when needed, so, is it possible to avoid the need of using PHP session when using the HybridAuth?

[1] http://hybridauth.sourceforge.net/userguide/HybridAuth_Sessions.html

2

There are 2 best solutions below

1
symcbean On

Short answer is no.

A longer answer is that it is possible (but in most cases will require sessions on the authentication provider) but to explain the options here would take far too long and from the tone of your question you would need a very detailed description of the potential options.

But this based on a premise that you can't have sessions across multiple machines. This is trivial. Even running sessions across multiple datacentres is a simpler solution And since you don't appear to be using the session for anything other than authentication you are not going to run into problems of scalability.

0
Yvan On

If you don't use PHP session mechanism for your application, you can override the default session storage by creating your own storage functions, with awareness of multiple servers.

For instance: http://php.net/manual/en/function.session-set-save-handler.php

You can then either set the session in Memcached (for this particular case, you should only use php.ini with the following instructions: http://php.net/manual/fr/memcached.sessions.php), or MySQL, or a physical storage accessible by all servers (such as NFS).

Although, I think that even if you have multiple servers, default is to redirect the user to the same IP address (in DNS Round-Robin declaration, or in standard load-balancers), so a unique storage on each server, not visible by the other servers, should work.