Title: invalidate a cookie
Last modified: August 22, 2016

---

# invalidate a cookie

 *  Resolved [usergoodvery](https://wordpress.org/support/users/usergoodvery/)
 * (@usergoodvery)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/invalidate-a-cookie/)
 * Hi Ali I hope u r doing well.
    Is there a way to invalidate a previously generated
   cookie? my app (android) needs to be able to log out users and have their session(
   one of which refers to a connection with wp via a cookie generated using your
   api). The problem is when I log the user back into my app and contact wp again
   for a new cookie, wp thinks the user is still logged in because the auth cookie
   is still current and fools my application, hence why i need to invalidate the
   cookie when the user logs out of my app. thanks for your input
 * [https://wordpress.org/plugins/json-api-user/](https://wordpress.org/plugins/json-api-user/)

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

 *  Plugin Author [Ali Qureshi](https://wordpress.org/support/users/parorrey/)
 * (@parorrey)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/invalidate-a-cookie/#post-5947467)
 * you can define minutes for generating cookie. just provide the ‘seconds’ var 
   value.
 * Optional ‘seconds’ var. It provided, generated cookie will be valid for that 
   many seconds, otherwise default is for 14 days.
 * **example:**
    generate cookie for 1 minute: [http://localhost/api/user/generate_auth_cookie/?username=john&password=PASSWORD-HERE&seconds=60](http://localhost/api/user/generate_auth_cookie/?username=john&password=PASSWORD-HERE&seconds=60)
 *  Thread Starter [usergoodvery](https://wordpress.org/support/users/usergoodvery/)
 * (@usergoodvery)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/invalidate-a-cookie/#post-5947471)
 * good tip thanks. is there a way to invalidate on demand though, instead of timed
   event like you just descried? I need to be able to invalidate when user hits 
   logout to reset the application’s internal state. Seems like an obvious thing
   to me. What happen when a user logs out of wp? doesn’t invalidate the the cookie?
   is there the equivalent of logout call?
 *  Plugin Author [Ali Qureshi](https://wordpress.org/support/users/parorrey/)
 * (@parorrey)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/invalidate-a-cookie/#post-5947475)
 * unfortunately no, when the cookie is issued, it is for a time.. the normal issued
   cookies are not stored in db, rather written in the cookies of browser.. so in
   our api case, once cookie is issued for a certain time, it remains valid.
 * I think you can forget/destroy cookie value on logging off in your app for user
   so that next time user hits api for any endpoint, its cookie value is absent.
   so user wont be able to connect until he gets fresh cookie..
 *  Thread Starter [usergoodvery](https://wordpress.org/support/users/usergoodvery/)
 * (@usergoodvery)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/invalidate-a-cookie/#post-5947490)
 * great thanks and keep up the good work.
 *  Thread Starter [usergoodvery](https://wordpress.org/support/users/usergoodvery/)
 * (@usergoodvery)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/invalidate-a-cookie/#post-5947492)
 * actually one last question, what about when you get the cookie as a result of
   registration, how do you control the time-to-live value?
 *  Plugin Author [Ali Qureshi](https://wordpress.org/support/users/parorrey/)
 * (@parorrey)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/invalidate-a-cookie/#post-5947493)
 * good one.. this will be updated too.
 * currently, you cant limit the time limit for it. I will update that this weekend.
   It will be same, just provide seconds var and it will use that limit.
 *  Thread Starter [usergoodvery](https://wordpress.org/support/users/usergoodvery/)
 * (@usergoodvery)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/invalidate-a-cookie/#post-5947495)
 * beautiful much appreciated

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

The topic ‘invalidate a cookie’ 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/)

 * 7 replies
 * 2 participants
 * Last reply from: [usergoodvery](https://wordpress.org/support/users/usergoodvery/)
 * Last activity: [11 years, 4 months ago](https://wordpress.org/support/topic/invalidate-a-cookie/#post-5947495)
 * Status: resolved