# Hide/Delete a cookie when stored in cache

**URL:** <https://www.ruby-forum.com/t/hide-delete-a-cookie-when-stored-in-cache/222475>\
**Category:** NGINX\
**Created:** [August 29, 2012, 7:04pm UTC](https://www.ruby-forum.com/t/hide-delete-a-cookie-when-stored-in-cache/222475 "2012-08-29T19:04:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [August 29, 2012, 7:04pm UTC](https://www.ruby-forum.com/t/hide-delete-a-cookie-when-stored-in-cache/222475/1 "2012-08-29T19:04:25Z")

</div>

Hello,

I’m caching pages with nginx using the following rules:

fastcgi\_no\_cache $cookie\_member\_id $is\_args  
fastcgi\_cache\_bypass $cookie\_member\_id $is\_args  
fastcgi\_ignore\_headers Cache-Control Expires Set-Cookie;

Now, there is a cookie (session\_id) that need to be passed to backed,  
but it  
shouldn’t be stored in the cache, since it’s the session\_id of a guest  
user  
and other guests should not see this.

Is there a way to store the page in the cache but before that, remove  
this  
cookie?

Thanks

Nuno

Posted at Nginx Forum:

> **[Hide/Delete a cookie when stored in cache](https://forum.nginx.org/read.php?2,230294,230294#msg-230294)**
>
> Hello, I'm caching pages with nginx using the following rules: fastcgi\_no\_cache $cookie\_member\_id $is\_args fastcgi\_cache\_bypass $cookie\_member\_id $is\_args fastcgi\_ignore\_headers Cache-Control Expires Set-Cookie; Now, there is a cookie (sessi

---

<div class="post-metadata">

**Author:** ![nfn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b19c9b/32.png) [@nfn](https://www.ruby-forum.com/u/nfn)\
**Post date:** [August 31, 2012, 11:55pm UTC](https://www.ruby-forum.com/t/hide-delete-a-cookie-when-stored-in-cache/222475/2 "2012-08-31T23:55:01Z")

</div>

Hello!

On Wed, Aug 29, 2012 at 01:04:13PM -0400, nfn wrote:

> and other guests should not see this.
> 
> Is there a way to store the page in the cache but before that, remove this  
> cookie?

Use

```
fastcgi_hide_header Set-Cookie;

```

See [Module ngx\_http\_fastcgi\_module](http://nginx.org/r/fastcgi_hide_header).

Maxim D.

---

<div class="post-metadata">

**Author:** ![nfn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b19c9b/32.png) [@nfn](https://www.ruby-forum.com/u/nfn)\
**Post date:** [September 1, 2012, 1:03am UTC](https://www.ruby-forum.com/t/hide-delete-a-cookie-when-stored-in-cache/222475/3 "2012-09-01T01:03:21Z")

</div>

Hello,

No dia Sexta-feira, 31 de Agosto de 2012, Maxim  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > fastcgi\_ignore\_headers Cache-Control Expires Set-Cookie;
> 
> Use
> 
> ```
> fastcgi_hide_header Set-Cookie;
> 
> ```
> 
> See [Module ngx\_http\_fastcgi\_module](http://nginx.org/r/fastcgi_hide_header).
> 
> Maxim D.

I can’t use hide\_header because It will hide all cookies. I just want to  
hide/delete session\_id cookie  
Any ideas?

Thanks,

Nuno
