# \[JavaScript\] Unable to Set Cookie

**URL:** <https://forum.kirupa.com/t/javascript-unable-to-set-cookie/183974>\
**Category:** web dev\
**Created:** [March 31, 2006, 5:06pm UTC](https://forum.kirupa.com/t/javascript-unable-to-set-cookie/183974 "2006-03-31T17:06:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MiddleFingerMan](https://avatars.discourse-cdn.com/v4/letter/m/bbce88/32.png) [@MiddleFingerMan](https://forum.kirupa.com/u/MiddleFingerMan)\
**Post date:** [March 31, 2006, 5:06pm UTC](https://forum.kirupa.com/t/javascript-unable-to-set-cookie/183974/1 "2006-03-31T17:06:32Z")

</div>

I’ve got a popup that launches when a person hits the page that has a link to have the person set the page as their home page. I want that link to:

1. Set the viewer’s home page to the current page
2. Set a cookie (so they don’t get the popup next visit)
3. Close the window

I tried making a single function to be called onClick but it didn’t work. I then added into the link itself to get it going and everything (except the cookie setting) works.

```auto
<a href="#" onClick="this.style.behavior='url(#default#homepage)'; this.setHomePage('http://myron/'); document.cookie='name=myronHomePage expires=01/01/2007 00:00:00'; MyWindow=window.close();">Please click here to make this your default homepage!</a>

```

I’m pretty new to JavaScript so I’m just sitting here getting frustrated! :hair:

What the heck am I doing wrong here?
