🍪Cookies
Now we'll learn how to edit-get-set cookies
req.cookie //Returns you the cookies
req.setcookie("malkubi","aptabotcuyiit")//unlimited time
// In here you created a new cookie named malkubi and value is 1
//If you want to make your cookie has a
req.setcookie("geçiciMalKubi","aptabotcuyiit",3600)//time on ms
//If you want to delete a cookie
req.delcookie("malkubi")
// OR
req.removecookie("malkubi")
//------------------------------------------------------------\\
// Example Code
if(!req.cookie.malkubi) return res.reditect("/404")
res.text("Wow you are logged in")
/*
In this code example it is checking if do you have a cookie named malkubi
and if is not than it'll redirect you to /404 page, if you are logged in than it'll
send you a text
\\------------------------------------------------------------//
*/
Last updated
Was this helpful?