# Removing a Cookie value using regex

**URL:** <https://discourse.haproxy.org/t/removing-a-cookie-value-using-regex/1399>\
**Category:** Help!\
**Created:** [July 4, 2017, 1:46am UTC](https://discourse.haproxy.org/t/removing-a-cookie-value-using-regex/1399 "2017-07-04T01:46:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sbonar](https://avatars.discourse-cdn.com/v4/letter/s/db5fbb/32.png) [@sbonar](https://discourse.haproxy.org/u/sbonar)\
**Post date:** [July 4, 2017, 1:46am UTC](https://discourse.haproxy.org/t/removing-a-cookie-value-using-regex/1399/1 "2017-07-04T01:46:36Z")

</div>

I am trying to remove a cookie value by using the following:

**http-request replace-header Cookie (;?\ ?sessionid=[^;]_;?\ ?)(._|\r\n) \2**

If I have read the docs correctly this will find the ‘sessionid’ cookie value in the Cookie header and replace it with whatever comes after it, whether it is a string or a ‘\r\n’.

This appears to work, for the most part, but there are times that it also removes the values before it.

1. what am I doing wrong???
2. is there another way to do this??

Scott
