SaraVieira / awesome-talks

Awesome Talks Curated By the Community
MIT License
809 stars 62 forks source link

Lets have some cookies 🍪 #88

Closed sudovijay closed 6 years ago

sudovijay commented 6 years ago

As we doing SSR and storing favs and watched videos in localStorage, There's no way we can access that on server level so right now neither of them seems to be working as they are kinda limited with session more or less. One way to do is re render few stuff at client side when the app actually get mounted Even the dark mode fall to default as we ain't storing the state anywhere

Other way is to have cookies, though they have this limit of 4k (4096 bytes) but i quess that'll be enough for our purpose. Cookies are perfect for dark mode too

On server side we can either parse cookies with node or use express with cookies parser middleware to parse cookies from request and use that for our purpose.

And, who doesn't like cookies, anyway?

SaraVieira commented 6 years ago

I don't have any experience with cookies and also by adding this we would have to add a warning telling the user that we are storing cookies :(

I'm super okay with this but I don't have the experience to do this

sudovijay commented 6 years ago

I'm super okay with this but I don't have the experience to do this

Now thats weird, the Great @SaraVieira don't have experience with cookies, i thought she like cookies too .. Well, i'll try to do this tonight, tbh there's no way we could achieve this without cookies as we doing SSR. I mean we could do something like storing user ip & settings in server but that'll be too much stuff tbh , and yes we have to add that warning thing, Thanks to EU Cookie Law 🇪🇺

SaraVieira commented 6 years ago

I like to consume them, not create them :p .

Here are is a package for the law: https://github.com/buildo/react-cookie-banner

Just saw that we use cookies for favorites, watched and also check if you like dark mode and saw this banner already ahah

sudovijay commented 6 years ago

I like to consume them, not create them :p .

But you should know how to create them too. You never know when you have to :P

Anyway we could totally avoid using that package if you wanted too as all it doing is creating a CookieBanner component and setting a cookie when user sees it so that user never sees that again until the cookie expires , just too many dependencies, just sayin 🙂

And for handling cookies we could do this own our own but that will be too many regex & stuff on document.cookie instead we could use something like this, it makes things alot simple https://github.com/js-cookie/js-cookie

sudovijay commented 6 years ago

done in #89, Closing now .