How to add multiple cookie names and values #5100
sriharsha-alphanome
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am using rx.script and rx.call_script for setting multiple cookies without rx.cookie as it only su[supports one name and value , I needed multiple names and multipl values i.e multiple cookies andI tried running gthe below script and I can see the log everything was being passed to this set_jwt_cookie but somehow rx.call_script was not being called or returned . Can somehow help me with this ?
`"""global auth base state"""
from typing import Dict, Any, Optional
import reflex as rx
class AuthState(AuthBaseClass):
"""Combined authentication and cookie management state."""
def cookie_script() -> rx.Component:
return rx.script("""
window.cookieUtils = {
getCookie: function(name) {
const decoded = decodeURIComponent(document.cookie);
const cookies = decoded.split('; ');
for (let cookie of cookies) {
if (cookie.startsWith(name + '=')) {
return cookie.substring(name.length + 1);
}
}
return '';
},
`
Beta Was this translation helpful? Give feedback.
All reactions