• Resolved usergoodvery

    (@usergoodvery)


    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://ww.wp.xz.cn/plugins/json-api-user/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Ali Qureshi

    (@parorrey)

    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

    Thread Starter usergoodvery

    (@usergoodvery)

    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

    (@parorrey)

    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

    (@usergoodvery)

    great thanks and keep up the good work.

    Thread Starter usergoodvery

    (@usergoodvery)

    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

    (@parorrey)

    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

    (@usergoodvery)

    beautiful much appreciated

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

The topic ‘invalidate a cookie’ is closed to new replies.