Using cookie while on local

Hello,

I would like to use cookie on local to test. When I run the app with the command fdk run, the document.cookie always throws an empty string. If I run it on a server like http://127.0.0.1:5500/, it works. However, I want to use the cookie when running fdk run. Is there any way to do that?

Thank you very much.
Nhat Nguyen

Hi @Nhat_Nguyen,
Good Day!
since our app is rendering in Iframe you can’t set the cookie directly, as per the latest security fix from the browser (always block third party cookie) and you need to set explicitly SameSite=none
kindly refer to this for link for more detail.
Hope it helps :slight_smile:

Thanks

Hello,
Thanks for your quick answer. As I have researched, I have to set Cookie SameSite on the server-side because it is HttpOnly Tag. Therefore, I want to setCookie on serverless app, however, I don’t know how to do it. How to set Cookie HttpIOnly Tag in serverless app?

Thank you.
Nhat Nguyen

@Nhat_Nguyen,
You mean you are setting a cookie from our serverless app (server.js) and are you using any HTTP server to request and getting a response if so please refer to this link for more reference.

if this solution is not working, can you please explain in more detail what you are trying to solve?

Thanks

@Nhat_Nguyen - As I understand from your question, you wanted to browser cookies for your app. As @Santhosh mentioned the app loads in an iframe within the host freshworks product.

From the above question, I can understand that you’ve discovered that a certain attribute has to be set up to host Freshworks’ product’s serverside. The serverless nature of our platform isn’t actually used for that purpose as you might be figuring out.

A lot of developers usually use cookies for some kind of storage. Freshworks platform has a platform API that can enable you to persist data - client.data.set(..). But we can only validate if this is feasible based on your use case or what you might be using cookies for. Can you please elaborate?

If it turns out to something we cannot solve using platform APIs – I can convert this topic as a feedback item pass on to the product team to see if they consider to allow apps in iframe set cookies (if possible – governed by browsers).

Hello,

Thank you for your answer. I think the client.data.set() is a good idea. I had tried to set the cookie but as you said, it didn’t work. For now, I am not really in need of using the cookie anymore. It is just a question from my team to check, now we do not have a special need for it.
Thank you for your attention to this topic.

1 Like