First I know nothing about .js!
Can you tell from this little snippet when the cookie is set to expire?
this.set_cookie(kw_cookie, new_kw, 86400 * 365);
Does the 365 indicate 1 year?
If you wanted it to expire in say 30 days, would it say 30 days there.
If I have the wrong snippet please let me know and I can copy and paste the thing in it's entirety.