Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

We are trying to use S2Member to manage our WP site and memberships for a Flash program that we are launching. We'd like to use S2Member to authenticate the user when they login and remain logged in.

Problem: The Java layer needs to know which user is logged into Wordpress (if any), so it can return the correct data to the flash layer.

Proposed Solution: The cookies that Wordpress should also be included with the requests from Flash to Java. Java could use those cookies to query against the Wordpress DB to obtain the user ID.

What we need to know: 1. Is it possible to get the user ID with the cookies from the DB or file system? Or is the cookie to user mapping only stored in memory? 2. What would be the method of obtaining the user id with the cookies? Could you provide some sample code that we could port to Java?

I'm not seeing a quick explanation / documentation on how to pull session info?

Wordpress comes with standard cookies, and i can read those cookies. Example : name value wordpress_fb2bd0842e9484b3403201e8bfb02ad3 admin%7C1328063097%7C983c44c0d712ba8bf7638b2cbb458842

With this info, how can we determine if this is a valid user?

share|improve this question
add comment

1 Answer

Why don't you write a quick plugin ... called "is user logged in" that registers a URL call.

So the user hits the page, then the Flash or Java could just hit:

http://mysite.com/customurl?hash=wordpress_logged_in_[hash]

Then the plugin would run and return true or false.

References:

http://codex.wordpress.org/WordPress_Cookies#WP_.3E_3

This way you keep everything within reach of the WordPress core toolset. So if you need to access the authentication API or any other tools you can.

If you do end up going this route I recommend making use of the Rewrite API:

http://codex.wordpress.org/WordPress_API's

Best of luck!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.