How to delete session cookie in Postman?

后端 未结 12 1390
渐次进展
渐次进展 2020-12-05 01:18

I am testing my API in Postman and am having trouble simulating a log out.

If I do a call to delete the session cookie,

相关标签:
12条回答
  • 2020-12-05 02:10

    Postman 4.0.5 has a feature named Manage Cookies located below the Send button which manages the cookies separately from Chrome it seems.

    0 讨论(0)
  • 2020-12-05 02:10

    new version of postman app has the ability to do that programmatically in pre-request or tests scripts since 2019/08

    see more examples here: Delete cookies programmatically · Issue #3312 · postmanlabs/postman-app-support

    clear all cookies

    const jar = pm.cookies.jar();
    
    jar.clear(pm.request.url, function (error) {
      // error - <Error>
    });
    

    get all cookies

    const jar = pm.cookies.jar();
    
    jar.getAll('http://example.com', function (error, cookies) {
      // error - <Error>
      // cookies - <PostmanCookieList>
      // PostmanCookieList: https://www.postmanlabs.com/postman-collection/CookieList.html
    });
    

    get specific cookie

    const jar = pm.cookies.jar();
    
    jar.get('http://example.com', 'token', function (error, value) {
      // error - <Error>
      // value - <String>
    });
    
    0 讨论(0)
  • 2020-12-05 02:14

    Note that this answer applies only to the standalone Postman UI and not the Postman app/add-on for Chrome.

    How to clear the cache in Postman (so that you are required to log in again when requesting a token, for example):

    • navigate to View: Show DevTools
    • navigate to the Application tab, then the Clear Storage view in the left menu
    • deselect all choices except Cache Storage, then click on ‘Clear site data’
    • restart Postman
    • you should now be prompted to log in again when requesting a new token
    0 讨论(0)
  • 2020-12-05 02:18

    As @markus said use the "Cookie Manager" and delete the cookie.

    If you want to learn how to set destroy cookies in postman, You should check the Postman Echo service https://docs.postman-echo.com/

    There you will find complete explanation on how to Set, Get and Delete those cookies.

    Check it on : https://docs.postman-echo.com/#3de3b135-b3cc-3a68-ba27-b6d373e03c8c

    Give it a Try.

    0 讨论(0)
  • 2020-12-05 02:18

    Is the Postman Interceptor enabled? Toggling it will route all requests and responses through the Chrome browser.

    Interceptor - https://www.getpostman.com/docs/capture Cookies documentation - http://blog.getpostman.com/index.php/2014/11/28/using-the-interceptor-to-read-and-write-cookies/

    0 讨论(0)
  • 2020-12-05 02:18

    You can use the Postman interceptor.That you can add into the chrome extension by this link:https://chrome.google.com/webstore/detail/postman-interceptor/aicmkgpgakddgnaphhhpliifpcfhicfo

    This helps you send requests which use browser cookies through the Postman app. It can also send headers which are normally restricted by Chrome but are critical for testing APIs.

    And also you can enable by interceptor which is there beside the orange sync icon

    0 讨论(0)
提交回复
热议问题