# Refresh a cookie expiration

**URL:** <https://community.f5.com/t/refresh-a-cookie-expiration/33689>\
**Category:** Technical Forums\
**Tags:** irules, dev, devops, application-delivery\
**Created:** [March 3, 2009, 8:18am UTC](https://community.f5.com/t/refresh-a-cookie-expiration/33689 "2009-03-03T08:18:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gregor\_33926](https://avatars.discourse-cdn.com/v4/letter/g/258eb7/32.png) [@Gregor\_33926](https://community.f5.com/u/Gregor_33926)\
**Post date:** [March 3, 2009, 8:18am UTC](https://community.f5.com/t/refresh-a-cookie-expiration/33689/1 "2009-03-03T08:18:33Z")

</div>

Hi

I was wondering if anyone could help me with an irule.

I have a number of checks it does but one part is basically, if a user hasn’t got a cookie and the maximum limit isn’t reached, give them a cookie with X min expiration and let them through. If they have a cookie let them through no matter what. When the X mins expires the users session timeout. Which is what i initially wanted, now though if a user refreshes a page i want the expiration time to basically reset.

Curently I have this

when HTTP\_RESPONSE {

If cookie didn’t exist give a cookie with timeout of 5 mins

if {$need\_cookie == 1}{

HTTP::cookie insert name “ticketcookie” value “ticketcookie”

HTTP::cookie expires “ticketcookie” “300” relative

HTTP::cookie path “/”

HTTP::cookie domain “.example.co.uk”

if {$::debug}{ log local0. “Sending cookie to [IP::client\_addr]”}

}

}

And thought of just doing something like this…

when HTTP\_RESPONSE {

If cookie didn’t exist give a cookie with timeout of 5 mins

if {$need\_cookie == 1}{

HTTP::cookie insert name “ticketcookie” value “ticketcookie”

HTTP::cookie expires “ticketcookie” “300” relative

HTTP::cookie path “/”

HTTP::cookie domain “.example.co.uk”

if {$::debug}{ log local0. “Sending cookie to [IP::client\_addr]”}

} elseif {$need\_cookie == 0} {

HTTP::cookie expires “ticketcookie” “180” relative

}

}

is there a reset command i am unaware of i could use. does the modification look like it’ll work.
