0

I've created a cookie in Scala, which I would like Javascript to be able to delete and/or modify.

Here is how I created the cookie in Scala ensuring the httpOnly param is set to false: ( Sticky Cookies in Scala )

I used the following method to delete the cookie in JavaScript, but the cookie does not delete. ( javascript - delete cookie )

Aside from attempting to delete the cookie, it doesn't seem like I can modify the contents of the cookie either.

How can I ensure the JavaScript can modify and delete the cookie created in Scala?

Community
  • 1
  • 1
jaxim
  • 515
  • 1
  • 9
  • 20
  • Are you trying to delete the cookie on the client viewing your web site? That would have nothing to do with scala - it's all in browser, on the client's computer. – childofsoong Jun 01 '15 at 23:43
  • I am attempting to delete and/or modify the cookie in the browser using JavaScript. Immediately after I make a change or delete it, I use JavaScript to see the change. However, no change is observed. Do I have to set the cookie in a special way in Scala to allow the client/JavaScript to make changes to the cookie? – jaxim Jun 02 '15 at 01:27

1 Answers1

0

I fixed the issue. I had to ensure that both the cookie created in Scala and the one deleted/modified in JavaScript both had the same path.

For example, in Scala:

new Cookie(sCookieID, sValue, Option(nSecondsExpire), "/", scala.None, false, false)

In JavaScript:

document.cookie = sCookieID + "=" + sValue+ "; " + sExpire + "; path=/";

Notice the path in both examples used "/". Once I used the same path, I was able to delete/modify the cookies in JavaScript. Before this I hadn't explicitly set the path in the JavaScript code.

jaxim
  • 515
  • 1
  • 9
  • 20