Score:0

Redirecting Users to Specific Files With Cookies

mt flag

Might be a dumb question, but I hope someone can explain it to me in a simple way for a beginner to understand.

Say I had a file only logged in users to my WordPress site are allowed to access. If I use a variable in nginx to redirect logged in users to that file based on the presence of the logged in cookie, such as:

if ($http_cookie ~* "(wordpress_logged_in_)") {
return blah
}

Would that be a proper, safe, or acceptable use or no?

sv flag
I'd recommend to migrate the question to https://security.stackexchange.com/ .
Michael Hampton avatar
cz flag
What do you mean by "proper", "safe", and "acceptable"?
sv flag
https://nginx.org/en/docs/http/ngx_http_secure_link_module.html may give an idea what is possible with Nginx.
Score:0
us flag

It's possible I don't properly understand the question; but theoretically you shouldn't be using the presence of a cookie to determine whether the user is logged in, you should be using an encrypted (access-token) value within the cookie - that only the server can decrypt, to allow you to know that the user is (still) logged in and even what roles (if not possibly also what 'claims' they have in relation to 'authorisation' and when the session/access-token will expire), aka an 'authentication' (& 'log out'/end-session) process, ideally one that is OAuth v2 based if not also (ideally) supporting OIDC(/OID-C/'Connect') too.

mt flag
This was very helpful, thanks!
sv flag
@JohnDeere If an answer is helpful, please upvote it! https://serverfault.com/help/someone-answers
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.