208
Views
4
Comments
Solved
How to get cookies using javascript
Application Type
Traditional Web

Hey All,

I am trying to set cookies on button click using javascript and once cookies set I want to read that cookies and show in feedback message or in expression.

Is there any way to implement this?

My result is

document.cookie

'DEVICE_OS=windows; DEVICE_BROWSER=chrome; DEVICES_TYPE=phone; DEVICE_ORIENTATION=landscape; pageLoadedFromBrowserCache=true; result_test=true'

from above result want to read last cookie named as result test.

Note:I tried using HTTPRequestHandler ->GetCookie server action but its not reading cookie which place at last.

In runjavascript I had setting value for document.cookie.

document.cookie = 'result_test='+value+';path=/;expires='+dt.toGMTString()+';';

Thanks in advance

Yogesh

2023-12-14 09-56-57
Yogesh Javir
Solution

I got solution,i created javascript function at screen level and called same function inside javascript.

Thanks

Yogesh

2024-01-31 05-29-41
Akshay Deshpande

Hello Yogesh, 

you need to set cookies first then you will get the cookies for reference I have attached the Screen shot with both first set cookie with the value and get the same cookies where you want (one time set and used same cookie value every time)

Thanks and Regards,

Akshay Deshpande

2023-12-14 09-56-57
Yogesh Javir

Hi @Akshay Deshpande 🚀 

Thanks for quick response.

I have written some javascript code using RunJavaScript from HTTPRequestHandler. I already set cookies inside RunJavaScript.

I want to read that cookies only which set using Javascript.

Any suggestion.

Thanks

Yogesh

2024-01-31 05-29-41
Akshay Deshpande

As far I  know you. Need to set cookie in that action.if it's not work check for others rply.(check you are using the same name for cookies for set and get )

2023-12-14 09-56-57
Yogesh Javir
Solution

I got solution,i created javascript function at screen level and called same function inside javascript.

Thanks

Yogesh

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.