Title: Call validation from other controller
Last modified: October 11, 2016

---

# Call validation from other controller

 *  Resolved [chetan.g](https://wordpress.org/support/users/chetang-1/)
 * (@chetang-1)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/call-validation-from-other-controller/)
 * I want to call the method of validate_auth_cookie of user controller from any
   other controller. can please let me know any example for this, I want to call
   some method of a controller after just validate the authentication.

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Ali Qureshi](https://wordpress.org/support/users/parorrey/)
 * (@parorrey)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/call-validation-from-other-controller/#post-8279893)
 * Hi,
 * This is how you can authenticate user for valid cookie in any other method:
 * `$user_id = wp_validate_auth_cookie($json_api->query->cookie, 'logged_in');`
 * If cookie is correct, you get $user_id, otherwise false.
 *  Thread Starter [chetan.g](https://wordpress.org/support/users/chetang-1/)
 * (@chetang-1)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/call-validation-from-other-controller/#post-8279922)
 * Thanks ali for the answer, could you please tell me one more thing that, I want
   to generate the token from any other controller as well? In that controller method
   I got the username and password of the user for login and registration.
 *  Plugin Author [Ali Qureshi](https://wordpress.org/support/users/parorrey/)
 * (@parorrey)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/call-validation-from-other-controller/#post-8279961)
 * do you want to generate ‘cookie’ or ‘nonce’? What do you mean by token?
 * You just need to use /api/user/generate_auth_cookie/ and /api/get_nonce/
 *  Thread Starter [chetan.g](https://wordpress.org/support/users/chetang-1/)
 * (@chetang-1)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/call-validation-from-other-controller/#post-8280010)
 * Ohh I mean to say generate `cookie` which I used as a `token` in response sending
   after authentication gets successful and when ever api hits any other method 
   of any other controller need to check the `cookie` or `token`, if it will verified
   proceed further, otherwise show error message.
 * SO I want to generate the cookie without calling /api/user/generate_auth_cookie/,
   I want to generate in a different controller method. now I hope you got my point.
 *  Plugin Author [Ali Qureshi](https://wordpress.org/support/users/parorrey/)
 * (@parorrey)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/call-validation-from-other-controller/#post-8280029)
 * if you generate the cookie with this Auth or User controller, it will work for
   all controllers. it just has to be valid.
 * you validate cookie calling this in every controller:
 * `$user_id = wp_validate_auth_cookie($json_api->query->cookie, 'logged_in');`

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Call validation from other controller’ is closed to new replies.

 * ![](https://ps.w.org/json-api-user/assets/icon-256x256.png?rev=1965790)
 * [JSON API User](https://wordpress.org/plugins/json-api-user/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/json-api-user/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/json-api-user/)
 * [Active Topics](https://wordpress.org/support/plugin/json-api-user/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/json-api-user/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/json-api-user/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Ali Qureshi](https://wordpress.org/support/users/parorrey/)
 * Last activity: [9 years, 7 months ago](https://wordpress.org/support/topic/call-validation-from-other-controller/#post-8280029)
 * Status: resolved