# Sticky sessions cookie issue

**URL:** <https://community.a10networks.com/t/sticky-sessions-cookie-issue/243>\
**Category:** ADC - Application Delivery\
**Tags:** cookie, slb-adc\
**Created:** [December 16, 2013, 1:06pm UTC](https://community.a10networks.com/t/sticky-sessions-cookie-issue/243 "2013-12-16T13:06:36Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![PjarInk](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@PjarInk](https://community.a10networks.com/u/PjarInk)\
**Post date:** [December 16, 2013, 1:06pm UTC](https://community.a10networks.com/t/sticky-sessions-cookie-issue/243/1 "2013-12-16T13:06:36Z")

</div>

Hello

I have an issue with sticky sessions, currently we’re using a cookie set by the AX on http-request, the issue I have (it’s a webshop) is that upon checkout, the store switches from http to https and thus we get a new cookie and there’s a high probability that the shopping cart is lost due to server switch.

This is one possible solution: [https://www.a10networks.com/vadc/index.php/forums/topic/aflex-for-individual-server-cookie-persist/](https://www.a10networks.com/vadc/index.php/forums/topic/aflex-for-individual-server-cookie-persist/)

Though I don’t see how it would work, what makes it so that the AX knows what server to keep track of with that http-response cookie? (We already use JSESSIONID for other stuff).

Another solution I thought of is to somehow create the https-cookie upon the first http-request.  
Any ideas/thoughts?

---

<div class="post-metadata">

**Author:** ![thomas.hedstrommer\_a10networks.com](https://avatars.discourse-cdn.com/v4/letter/t/e0b2c6/32.png) [@thomas.hedstrommer\_a10networks.com](https://community.a10networks.com/u/thomas.hedstrommer_a10networks.com)\
**Post date:** [December 16, 2013, 1:41pm UTC](https://community.a10networks.com/t/sticky-sessions-cookie-issue/243/2 "2013-12-16T13:41:38Z")

</div>

Hi, try to set the cookie persistence template to match type server on both port 80 and port 443.  
I believe that should do the trick.

Kind regards,  
Thomas

---

<div class="post-metadata">

**Author:** ![PjarInk](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@PjarInk](https://community.a10networks.com/u/PjarInk)\
**Post date:** [December 16, 2013, 1:55pm UTC](https://community.a10networks.com/t/sticky-sessions-cookie-issue/243/3 "2013-12-16T13:55:58Z")

</div>

There is no option to specify ports in the cookie template, do I have to use a single service group with both ports specified?

---

<div class="post-metadata">

**Author:** ![thomas.hedstrommer\_a10networks.com](https://avatars.discourse-cdn.com/v4/letter/t/e0b2c6/32.png) [@thomas.hedstrommer\_a10networks.com](https://community.a10networks.com/u/thomas.hedstrommer_a10networks.com)\
**Post date:** [December 16, 2013, 2:12pm UTC](https://community.a10networks.com/t/sticky-sessions-cookie-issue/243/4 "2013-12-16T14:12:04Z")

</div>

What version are you on?

I am on version 2.7.1, cookie persistence, match type and change that from port to server.

BR  
Thomas

---

<div class="post-metadata">

**Author:** ![PjarInk](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@PjarInk](https://community.a10networks.com/u/PjarInk)\
**Post date:** [December 16, 2013, 2:32pm UTC](https://community.a10networks.com/t/sticky-sessions-cookie-issue/243/5 "2013-12-16T14:32:38Z")

</div>

Software Version: 2.7.1-P2(build: 57)  
Cookie persistance is on match service group, server and not on port.

---

<div class="post-metadata">

**Author:** ![PjarInk](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@PjarInk](https://community.a10networks.com/u/PjarInk)\
**Post date:** [December 17, 2013, 8:29am UTC](https://community.a10networks.com/t/sticky-sessions-cookie-issue/243/6 "2013-12-17T08:29:07Z")

</div>

Anyone else has any input?

I’m in quite a bind here.

---

<div class="post-metadata">

**Author:** ![thomas.hedstrommer\_a10networks.com](https://avatars.discourse-cdn.com/v4/letter/t/e0b2c6/32.png) [@thomas.hedstrommer\_a10networks.com](https://community.a10networks.com/u/thomas.hedstrommer_a10networks.com)\
**Post date:** [December 17, 2013, 10:29am UTC](https://community.a10networks.com/t/sticky-sessions-cookie-issue/243/7 "2013-12-17T10:29:45Z")

</div>

Are they located at the same virtual server?(i guess they are)  
Are both services set to use match type service?

Good luck,  
Thomas

---

<div class="post-metadata">

**Author:** ![mischa](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@mischa](https://community.a10networks.com/u/mischa)\
**Post date:** [December 17, 2013, 11:40am UTC](https://community.a10networks.com/t/sticky-sessions-cookie-issue/243/8 "2013-12-17T11:40:51Z")

</div>

We probably need to modify the aFleX you are using. Can you post your current script?

---

<div class="post-metadata">

**Author:** ![PjarInk](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@PjarInk](https://community.a10networks.com/u/PjarInk)\
**Post date:** [December 17, 2013, 11:45am UTC](https://community.a10networks.com/t/sticky-sessions-cookie-issue/243/9 "2013-12-17T11:45:43Z")

</div>

Thomas: Yes, they are at the same virtual server. I’m not following you, we have 1 template for the cookie where match type server is set. Where do I find match type service?

Mischa: Not using aflex, it’s a cookie persistance template at the moment, though I linked to that aflex as I think it’s a possible solution, but I want to understand how it works, because to my eyes all that script does is to check if there is a cookie and then save the info, I don’t see any connection between that info and which server to send the client to.

---

<div class="post-metadata">

**Author:** ![mischa](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@mischa](https://community.a10networks.com/u/mischa)\
**Post date:** [December 17, 2013, 4:44pm UTC](https://community.a10networks.com/t/sticky-sessions-cookie-issue/243/10 "2013-12-17T16:44:43Z")

</div>

The way it works is as follows.  
On the incoming client request a server is selected based on the load balancing method you have specified. One the server is selected a cookie is inserted, to the client only, which contains a hash of the destination server. Any subsequent request will be send to this server as long as the cookie is present.

The different match types will tell us for which requests we would use the same server. When the match type is port we will only forward requests to the specific port to which the template is applied. Which can mean that request via port 80 and port 443 will end up at different serves. By using match-type server you can prevent this.

The cookie template will need to look something like: `slb template persist cookie tp-cookie-persist match-type server `

Without an expire the cookie will be removed as soon as the browser closes.

This template needs to be applied to both ports, 80 and 443.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![PjarInk](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@PjarInk](https://community.a10networks.com/u/PjarInk)\
**Post date:** [December 18, 2013, 8:36am UTC](https://community.a10networks.com/t/sticky-sessions-cookie-issue/243/11 "2013-12-18T08:36:05Z")

</div>

We have it set up like that, at least in the gui, I will see if it differs in cli.

My guess is that we have either done something wrong in the server group/virtual server or there’s a bug in the gui showing us wrong information (match type server set, but not effective).

---

<div class="post-metadata">

**Author:** ![mischa](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@mischa](https://community.a10networks.com/u/mischa)\
**Post date:** [December 18, 2013, 9:07am UTC](https://community.a10networks.com/t/sticky-sessions-cookie-issue/243/12 "2013-12-18T09:07:50Z")

</div>

That could be the case. 2.7.1-P3 is available for download via our portal.

---

<div class="post-metadata">

**Author:** ![PjarInk](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@PjarInk](https://community.a10networks.com/u/PjarInk)\
**Post date:** [December 18, 2013, 10:17am UTC](https://community.a10networks.com/t/sticky-sessions-cookie-issue/243/13 "2013-12-18T10:17:07Z")

</div>

We have an update scheduled tonight, I will update with results.

---

<div class="post-metadata">

**Author:** ![PjarInk](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@PjarInk](https://community.a10networks.com/u/PjarInk)\
**Post date:** [December 19, 2013, 9:54am UTC](https://community.a10networks.com/t/sticky-sessions-cookie-issue/243/14 "2013-12-19T09:54:04Z")

</div>

So we performed the update and we see no different results. I suspect misconfiguration.

Could you go through how it should be set up or point me to a resource with instructions? Because what I have available today is not entirely logical or correct it seems.

---

<div class="post-metadata">

**Author:** ![mischa](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@mischa](https://community.a10networks.com/u/mischa)\
**Post date:** [December 19, 2013, 12:51pm UTC](https://community.a10networks.com/t/sticky-sessions-cookie-issue/243/15 "2013-12-19T12:51:14Z")

</div>

The steps are very simple.

```auto
1) Create an cookie persist template as mentioned.
2) Apply it to the virtual server ports.
3) Done... :)

```

But in order to do proper trouble shooting, would you be able to supply the running config or show tech?

---

<div class="post-metadata">

**Author:** ![PjarInk](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@PjarInk](https://community.a10networks.com/u/PjarInk)\
**Post date:** [December 19, 2013, 12:56pm UTC](https://community.a10networks.com/t/sticky-sessions-cookie-issue/243/16 "2013-12-19T12:56:04Z")

</div>

I might not be able to supply the running config, I can check. But I can describe the setup:  
2 service groups, app:80 and app:443, 1 virtual server pointing port 80 and 443 to respective service group. 2 virtual service, 80 and 443, both have the same cookie persist template.  
Most of the settings are default.

---

<div class="post-metadata">

**Author:** ![PjarInk](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@PjarInk](https://community.a10networks.com/u/PjarInk)\
**Post date:** [December 19, 2013, 1:03pm UTC](https://community.a10networks.com/t/sticky-sessions-cookie-issue/243/17 "2013-12-19T13:03:15Z")

</div>

Can I PM you somehow Mischa?

---

<div class="post-metadata">

**Author:** ![mischa](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@mischa](https://community.a10networks.com/u/mischa)\
**Post date:** [December 19, 2013, 1:15pm UTC](https://community.a10networks.com/t/sticky-sessions-cookie-issue/243/18 "2013-12-19T13:15:28Z")

</div>

Ah… that explains it. You are not using the same service-group for both port 80 and 443.

```auto
Where are you terminating the SSL session? On the AX or the Server?
No idea if you can PM me through this forum, but you can drop me an email on mpeters [at] a10networks [dot] com

```

---

<div class="post-metadata">

**Author:** ![PjarInk](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@PjarInk](https://community.a10networks.com/u/PjarInk)\
**Post date:** [December 19, 2013, 1:16pm UTC](https://community.a10networks.com/t/sticky-sessions-cookie-issue/243/19 "2013-12-19T13:16:57Z")

</div>

We are terminating it on the AX.

I thought we had something wrong there, I will test and configure both ports on one service group! Thanks.

---

<div class="post-metadata">

**Author:** ![PjarInk](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@PjarInk](https://community.a10networks.com/u/PjarInk)\
**Post date:** [December 19, 2013, 1:49pm UTC](https://community.a10networks.com/t/sticky-sessions-cookie-issue/243/20 "2013-12-19T13:49:48Z")

</div>

When I set http and https in one service group and use that, I get a redirect loop which I have a hard time understanding why it pops up. Any ideas?

[Next page](https://community.a10networks.com/t/sticky-sessions-cookie-issue/243.md?page=2)
