# Possible Syntax issue with HTTP::Cookie iRule

**URL:** <https://community.f5.com/t/possible-syntax-issue-with-http-cookie-irule/6163>\
**Category:** Technical Forums\
**Tags:** irules, dev, devops, application-delivery\
**Created:** [January 26, 2011, 8:29pm UTC](https://community.f5.com/t/possible-syntax-issue-with-http-cookie-irule/6163 "2011-01-26T20:29:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bob\_10976](https://avatars.discourse-cdn.com/v4/letter/b/838e76/32.png) [@Bob\_10976](https://community.f5.com/u/Bob_10976)\
**Post date:** [January 26, 2011, 8:29pm UTC](https://community.f5.com/t/possible-syntax-issue-with-http-cookie-irule/6163/1 "2011-01-26T20:29:13Z")

</div>

Hello all..

I have a working iRule in place and I need add to it, but it seems I’m getting some type of Syntax error.

The current iRule looks like this and as I said appears to work fine:

```tcl
when HTTP_RESPONSE {
if { [HTTP::cookie exists "ASP.net_SessionID"] } { 
HTTP::cookie secure "ASP.net_SessionID" enable
}
if { [HTTP::cookie exists ".ADAuthCookie"] } { 
HTTP::cookie secure ".ADAuthCookie" enable }
}

```

I’m simply wanting to add a third cookie reference:

```tcl
when HTTP_RESPONSE {
if { [HTTP::cookie exists "ASP.net_SessionID"] } { 
HTTP::cookie secure "ASP.net_SessionID" enable 
}
if { [HTTP::cookie exists ".ADAuthCookie"] } {
HTTP::cookie secure ".ADAuthCookie" enable }
} 
if { [HTTP::cookie exists "RS_User"] } {
HTTP::cookie secure "RS_User" enable }
}

```

When I do I get the following errors:

Line 8: [command is not valid in the current scope] [if {HTTP::cookie exist ‚ÄúRS\_User‚Äù]}{

Line 10: [command is no valid in the current scope][}]

Am I missing something here?

Thanks,

Bob

---

<div class="post-metadata">

**Author:** ![Chris\_Miller](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/chris_miller/32/14702_2.png) [@Chris\_Miller](https://community.f5.com/u/Chris_Miller)\
**Post date:** [January 26, 2011, 9:00pm UTC](https://community.f5.com/t/possible-syntax-issue-with-http-cookie-irule/6163/2 "2011-01-26T21:00:47Z")

</div>

You have an extra “}” above your final if statement. Give this a shot.

```tcl
when HTTP_RESPONSE {
if { [HTTP::cookie exists "ASP.net_SessionID"] } { 
HTTP::cookie secure "ASP.net_SessionID" enable 
}
if { [HTTP::cookie exists ".ADAuthCookie"] } {
HTTP::cookie secure ".ADAuthCookie" enable 
}
if { [HTTP::cookie exists "RS_User"] } {
HTTP::cookie secure "RS_User" enable 
}
}

```

That was originally there to close the HTTP\_REQUEST event. Looks like an additional was was correctly created at the end of the new rule but the original wasn’t removed.

---

<div class="post-metadata">

**Author:** ![Bob\_10976](https://avatars.discourse-cdn.com/v4/letter/b/838e76/32.png) [@Bob\_10976](https://community.f5.com/u/Bob_10976)\
**Post date:** [January 26, 2011, 9:22pm UTC](https://community.f5.com/t/possible-syntax-issue-with-http-cookie-irule/6163/3 "2011-01-26T21:22:15Z")

</div>

Ahhh!! Thank you..Works like a charm now..

Thanks,

Bob
