# Cookie issue with serval client

**URL:** <https://forum.inductiveautomation.com/t/cookie-issue-with-serval-client/93579>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [July 23, 2024, 5:17am UTC](https://forum.inductiveautomation.com/t/cookie-issue-with-serval-client/93579 "2024-07-23T05:17:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hui\_Xia](https://avatars.discourse-cdn.com/v4/letter/h/ee7513/32.png) [@Hui\_Xia](https://forum.inductiveautomation.com/u/Hui_Xia)\
**Post date:** [July 23, 2024, 5:17am UTC](https://forum.inductiveautomation.com/t/cookie-issue-with-serval-client/93579/1 "2024-07-23T05:17:31Z")

</div>

I try to create cookie to store some value in web browse ,after test with two different browses , I change one of their cookie , I restart another browse , it also change to the same value in first browse.

```python
from java.net import CookiePolicy
import java.net.URI
import java.net.HttpCookie
import system.net
"""
    for left view ,if don't find the stn ,use cookie stn .
"""

uri = java.net.URI("http://127.0.0.1:8088/data/perspective/client/TactBoard")
client = system.net.httpClient()
manager = client.getCookieManager()
cookieStore = manager.getCookieStore()

def SetCookie(name, value, maxAge=365 * 24 * 60 * 60):
    cookie = java.net.HttpCookie(str(name), str(value))
    cookie.setMaxAge(maxAge)
    cookieStore.add(uri, cookie)

def GetCookie(name):
    for cookie in cookieStore.get(uri):
        if cookie.name == name:
            return cookie.value
    return None

```

I use these code with try License. I want to know the reason is license or not .

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 23, 2024, 6:01am UTC](https://forum.inductiveautomation.com/t/cookie-issue-with-serval-client/93579/2 "2024-07-23T06:01:40Z")

</div>

You're sharing a single cookie store across all your scripts in a given scope (across the entire gateway). Cookies are stored there, and completely independent from browser cookie mechanisms, which are not accessible to any supported Perspective scripting mechanism.

What are you actually trying to do? Tell us that and we might be able to give you a better approach.

The trial license doesn't affect the way scripts execute, so it's not a factor here.

---

<div class="post-metadata">

**Author:** ![Hui\_Xia](https://avatars.discourse-cdn.com/v4/letter/h/ee7513/32.png) [@Hui\_Xia](https://forum.inductiveautomation.com/u/Hui_Xia)\
**Post date:** [July 23, 2024, 6:25am UTC](https://forum.inductiveautomation.com/t/cookie-issue-with-serval-client/93579/3 "2024-07-23T06:25:40Z")

</div>

I want to store different tagPath(restore to a view's parameter) which different client could show different infomation by cookies , if I use session , it will be lost after browse close ,so I try to use cookies or web localstorage.

---

<div class="post-metadata">

**Author:** ![Hui\_Xia](https://avatars.discourse-cdn.com/v4/letter/h/ee7513/32.png) [@Hui\_Xia](https://forum.inductiveautomation.com/u/Hui_Xia)\
**Post date:** [July 23, 2024, 6:37am UTC](https://forum.inductiveautomation.com/t/cookie-issue-with-serval-client/93579/4 "2024-07-23T06:37:28Z")

</div>

So is there any method If I want to store information in every client?

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [July 23, 2024, 6:40am UTC](https://forum.inductiveautomation.com/t/cookie-issue-with-serval-client/93579/5 "2024-07-23T06:40:00Z")

</div>

If they each have their own user login, you could store it in a database per user, otherwise not really

---

<div class="post-metadata">

**Author:** ![Hui\_Xia](https://avatars.discourse-cdn.com/v4/letter/h/ee7513/32.png) [@Hui\_Xia](https://forum.inductiveautomation.com/u/Hui_Xia)\
**Post date:** [July 23, 2024, 9:27am UTC](https://forum.inductiveautomation.com/t/cookie-issue-with-serval-client/93579/6 "2024-07-23T09:27:14Z")

</div>

OK ,thank you ,I try to use url parameter and create a function decode the parameter to information which I want to get.  
Do you know your company will develop the function with web localstorage or not , this is a popular technical in web develop.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 23, 2024, 2:49pm UTC](https://forum.inductiveautomation.com/t/cookie-issue-with-serval-client/93579/7 "2024-07-23T14:49:59Z")

</div>

No, I don't know. We've talked about it before, but coming up with a good API is challenging since all scripting is happening on the backend.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [July 24, 2024, 1:49pm UTC](https://forum.inductiveautomation.com/t/cookie-issue-with-serval-client/93579/8 "2024-07-24T13:49:43Z")

</div>

Its not impoosible (or even hard) to access/write to browsers localstorage with js injection.  
But even if you can ... just go to the database.  
It will be faster for most usecases anyways, Unless you also handle all the effects in the injected JS... But that will be a big mess to deal with.
