0

We have a website WordPress website running on AWS and it has ELB implemented on it. I have to save UTM data of each visitor whenever it reaches to our website and has to keep it for the whole session of a particular user.

I used $_SESSION for the same purpose it's in vain as we know AWS does not support $_SESSION on ELB. We searched for the alternative and found it that it can be possible by using Sticky Sessions on AWS.

Now, the problem is that we have no idea how we can implement Sticky Sessions. Can you please let us know how we can use Sticky Sessions on AWS?

Sanchit Gupta
  • 3,148
  • 2
  • 28
  • 36
BlueSuiter
  • 527
  • 6
  • 21
  • 1
    Just turn it on in the AWS Console for the ELB. – ceejayoz Jan 05 '17 at 19:13
  • Okay, and how we can use it in code. Is it have any special syntax or it is alike PHP core sessions. – BlueSuiter Jan 05 '17 at 19:17
  • 2
    You don't do anything in the code. Sticky sessions are for situations where you can't feasibly rewrite the code to use shared session storage like a DB or Redis. Turn it on and you're done - each user will hit one of your EC2 instances exclusively. – ceejayoz Jan 05 '17 at 19:22
  • 1
    Side note: "I used $_SESSION for the same purpose it's in vain as we know AWS not support $_SESSION on ELB" isn't true. It's entirely possible to get `$_SESSION` working on AWS. It'll work normally for any single server situation. With multiple servers, you need a [custom session handler](http://php.net/manual/en/session.customhandler.php) to save sessions somewhere shared - ElastiCache, RDS, etc. – ceejayoz Jan 05 '17 at 19:43
  • 1
    For scalability and reliability I would suggest moving to Elasticache, that way requests don't get pinned down to one instance. – strongjz Jan 16 '17 at 16:41
  • Thank You all for their contribution. We finally able to fix the issue we are facing. – BlueSuiter Jan 23 '17 at 12:59
  • Can you please post you fix as a solution for this question? I am also interested in the solution. In my case, I have enabled the sticky sessions in the ELB and now is working, but my question is still if this is real load balancing because the user is bind to one instance exclusively. Thank you – Morpheus_ro Feb 05 '17 at 11:29
  • The very first lines of **ELB** from **AWS** I think these will be helpful for understanding **ELB's** working. `Elastic Load Balancing automatically distributes incoming application traffic across multiple Amazon EC2 instances. It enables you to achieve fault tolerance in your applications, seamlessly providing the required amount of load balancing capacity needed to route application traffic.` – BlueSuiter Feb 06 '17 at 18:09

0 Answers0