Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
789 views
in Q2A Core by
On my main site, all the pages are heavily cached. (They are normally generated from a database but rarely change so I just serve the exact same HTML to every visitor.) For some minor user-interaction in the past I used Javascript to set/retrieve a preference cookie.

My question is, can I do something similar with Q2A? It looks like the qa_session cookie contains my username but has some other characters after it. What is the format?

Note, I really just need to check the username and display some links, which will go to special Q2A pages (for proper security). Kind of like when Amazon recognizes you but makes you login when you actually need to buy something.
Q2A version: 1.4

1 Answer

+1 vote
by

So if I understand correctly, you want to check whether a user is logged in from within a client-side Javascript? If so, checking the qa_session cookie is a good way to go. If a user is logged in it contains 3 fields which are slash-separated (a slash is %2F if urlencoded) and the first is the user's username.

by
Yep that's exactly what I want. The idea is to add quick links back to a Q2A plugin where the user will be properly validated.
Thanks, and Happy New Year!!
...