Skip to main content
14 events
when toggle format what by license comment
May 3, 2016 at 6:44 vote accept N00b
Mar 16, 2016 at 1:31 comment added fuxia There is no session. There are authentication cookies. See wp_set_auth_cookie() for the names and hooks to capture these. You still have to pass the data to JavaScript per HTML – with something like wp_localize_script(). That's how it works.
Mar 16, 2016 at 1:21 comment added N00b @toscho Yup, Im aware of that. I would validate it via ajax if user action requires "more strict" security and use JS solution for minor things that doesn't require strict security. Regular ajax calls with every action user takes would slow the navigation down big time which would make this experiment pointless. You seem to have a lot of experience with WP (over 5 years here alone), is there a way to capture session name when user logs in?
Mar 16, 2016 at 1:15 comment added fuxia You still have to validate that information on the server side with PHP for security.
Mar 16, 2016 at 0:06 comment added N00b @toscho This is not a solution to my problem. wp_localize_script() only checks if user is logged in if page is (re)loaded and might be invalid at some point in single page app (which doesn't require reloading). Im currently thinking if it's possible to: 1. Capture the session name if user logs in, is it possible? 2. Save it as user meta 3. Fetch it and save it as JS variable 4. Check if that session exists by name if needed (which is possible in JS) - e.g with every url/route change. Why I would need to capture the name? Because name (also value) is randomly generated.
Mar 15, 2016 at 22:04 comment added fuxia There is also wordpress.stackexchange.com/questions/50165/… and probably more.
Mar 15, 2016 at 22:04 history closed fuxia Duplicate of Check if user is logged in using JQuery
Mar 15, 2016 at 20:41 answer added Aamer Shahzad timeline score: 1
Mar 15, 2016 at 20:19 answer added Howdy_McGee timeline score: 0
Mar 15, 2016 at 20:16 answer added Bruno Cantuaria timeline score: 0
Mar 15, 2016 at 20:13 comment added Howdy_McGee Localization may be your best bet then.
Mar 15, 2016 at 20:12 comment added N00b @Howdy_McGee This is not going to work because whole DOM is generated via JS/React.js. I could hard-code this class but it can be hacked. Im wondering if there's a more secure way..
Mar 15, 2016 at 20:10 comment added Howdy_McGee This seems on the fence. body_class() has logged-in class which you could check for in JS. I think the best bet is to check all these things on init ( or a similar hook ) and localize them to your JS
Mar 15, 2016 at 20:05 history asked N00b CC BY-SA 3.0