(long post -- more like rants)
So the servers for the company where i worked for have decided to use a load balancer to .. well, balance the server load and keep it alive longer and better.
Everything seems to be working nicely. If people browse to http://ourcompany, they are redirected to either compi1 or compi2 transparently. Any read/write to the database is also synchronized nicely using triggers and whatever.
Now here's where the headache comes.
As the person working on the member and login information, i decided to use PHP's $_SESION.
All was nice in the beginning ...
The user log in to their account, i save the session information on the server, save the same information in database (which get sync-ed right away), and move along.
Sounds simple enough.
Except that, let's say if i'm logged in from compi1, and the next time i access our site from compi2, the user will be rejected and will be told to log in first since the $_SESSION information was only stored in compi1.
Meh.
So now i need to figure out a way such that the session information stored in compi1 is also made available on compi2. One of the ways i could think of is use both $_SESSION and $_COOKIE authentication to check for user's login. Session for server side, cookie for client site.
Another thing i tried was using ini_set ("session.cookie_domain", ".something_here.com");, but that doesn't seem to work as well.
I'm stumped.
Anyone have experience regarding doing sessions in load-balanced servers? How do you make sure the session information is shared across the different computers? Or maybe it's a simple thing to do and i'm just looking at it from too complicated point of view?
Thanks for reading ... i need more caffeine... -(
edit: i would put this in off topic, but i'm hoping that someone can shed the light and help with it.
if this post counts more towards rants than programmer's frustration with programming, feel free to move it.
So the servers for the company where i worked for have decided to use a load balancer to .. well, balance the server load and keep it alive longer and better.
Everything seems to be working nicely. If people browse to http://ourcompany, they are redirected to either compi1 or compi2 transparently. Any read/write to the database is also synchronized nicely using triggers and whatever.
Now here's where the headache comes.
As the person working on the member and login information, i decided to use PHP's $_SESION.
All was nice in the beginning ...
The user log in to their account, i save the session information on the server, save the same information in database (which get sync-ed right away), and move along.
Sounds simple enough.
Except that, let's say if i'm logged in from compi1, and the next time i access our site from compi2, the user will be rejected and will be told to log in first since the $_SESSION information was only stored in compi1.
Meh.
So now i need to figure out a way such that the session information stored in compi1 is also made available on compi2. One of the ways i could think of is use both $_SESSION and $_COOKIE authentication to check for user's login. Session for server side, cookie for client site.
Another thing i tried was using ini_set ("session.cookie_domain", ".something_here.com");, but that doesn't seem to work as well.
I'm stumped.
Anyone have experience regarding doing sessions in load-balanced servers? How do you make sure the session information is shared across the different computers? Or maybe it's a simple thing to do and i'm just looking at it from too complicated point of view?
Thanks for reading ... i need more caffeine... -(
edit: i would put this in off topic, but i'm hoping that someone can shed the light and help with it.
if this post counts more towards rants than programmer's frustration with programming, feel free to move it.