I made a discord bot which ranks group members but the cookie for the bot keeps expiring, is there any way that I can make the cookies not expire or at least last longer?
No way jose, I am pretty sure there is absolutely no way to get ANY cookie not to expire ( unless you own the site ). I recommend reading this to help you out with how cookies really work;
But is there a way to make the cookie last longer than 1 day
I’m almost afraid to say this on here due to what this these types of things can be used for. However, knowledge is power.
Cookies will always expire since they’re given to you by the site and along with your X-CSRF-TOKEN
help to track your session. You can get around this by logging into the site in incognito mode
, pressing F12
(if using Chrome), clicking Application
and then the Cookies
button on your left. From there, there’s a value called, .ROBLOSECURITY
. The value for that key is your authentication cookie. I cannot stress this enough as it’s a common mistake, do not share your cookies or leak them on chats. I’ve seen accounts get deleted, purged of Robux and completely ruined over small mistakes.
In my sole opinion, I believe that Roblox should integrated their existing solution to follow OAuth. Until then, I don’t see any other viable way.
Edit: There’s actually a multitude of libraries out there that help handle sessions and refresh cookies for you. One of them being Noblox.js
. (I’m not sure if Github links are allowed here).
It may be that whatever APi you are using for the discord bot respects cookie expirations or may even be clearing them out prematurely say with a bot restart. How to change this behavior is highly dependent on the language / APi used to develop the bot. As stated above, even if the client ignores cookie expirations, the server may still choose not to accept expired cookies or not maintain server-side data associated with the cookie after expiration.
As long as you access some page regularly with your cookie, you should be able to keep it valid for months.
However, I’ve had a web server running with a cookie for a while and I haven’t replaced it often.
It would expire in 1 day but if your script is actively using it then it will be kepted unexpired/
Very VERY late on this, but I feel like this needs to be said: Your .ROBLOSECURITY expires when you log-out with it.
In other words, logging out = invalidating current .ROBLOSECURITY cookie.
If you mean cookie as in cookie in a browser, you can’t prevent a cookie from expiring. But you can store it in your bot in a variable, and then just pass it back at each request.
Apologies for bumping this, but I feel like this should be said