http-only cookie Supabase - How to get a specific key
TL ;DR : How to get the cookies .user .user _metadata .user type ? _ _ I 'm trying to do something that I thought would be simple (in javascript at least ) but I 'm struggling with it . I 'm using the supabase template , and the cookie get saved in the http -only cookie . I 'm trying to retreive the value for user_type And the structure is like so : {
"access_token": "xx",
"user": {
"user_metadata": {
"user_type": "ORGANISATION"
}
}
}Attached the screenshot of what I 've tried to attempt . Any idea how to solve that ? Cookies are stored as strings so arrays and objects lose their shape if you try to save them directly . You can stringify the object before saving it as a cookie then when you go to call for it , use JSON parse to turn it back into an object THEN you can do the Get . Someone correct this if incorrect . You can 't access http -only cookies in the browser so you won 't be able to get this data . You can get those values directly from the jwt before it is stored , but that would involve editing the package . Alternatively you could call an edge function and call getClaims ( ) which would return all claims from the JWT . This is most secure and fast . I do it on every page load instead of getUser ( )


.jpeg/public)