0

I'm using (or I'm going to use) WordPress for my product's marketing site. I use Rails for the product's application.

Right now on my marketing site, which is currently in Rails, I have a link that reads either "My Account" or "Sign In" depending on whether you're signed in or not.

I'd like to duplicate this feature on my WP site but I of course won't have the privilege of doing it in as direct a way as I am on my Rails marketing site now.

I'm thinking I'll want to keep track via a cookie whether the user is logged in, which I assume is possible because the application and marketing site will both be on the same TLD.

What's not clear to me is what would be a good way to read that cookie in WP. Any suggestions?

1 Answer 1

0

You can read cookies both on the front- and back-end sides.

For the front-end, you have to provide both links, and show only the desired one with javascript. Use document.cookie.indexOf('cookie_name') to check the cookie presence.

For the back-end, you can read the special $_COOKIE variable to check the cookie presence in you template and change the link with this information.

The fact the your PHP application is inside Wordpress will not make much difference.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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