Login with PHP curl and CSRF token

后端 未结 3 883
忘了有多久
忘了有多久 2021-01-07 02:05

I want login from a PHP script to another website but I always get this reply:

403 Error: CSRF token mismatch

I extract the CSRF token from

3条回答
  •  猫巷女王i
    2021-01-07 02:29

    CSRF token genrated for every session. Read first comment ot yor question (@walkingRed comment) (comment deleted - cURL CSRF Token - this is solution). There solution of your problem.

    You should start your session on the another website and after this you can get correct csrf token.

    And it's important to using cookies with every request to define that your external request always in the same session.

    Example:

    You make first request to grab CSRF token. On the external website started new session for your request and generated csrf token.

    Then you make anohter request - but without using cookies - for this reuqest started new session again, and again generated new csrf token, for this new session.

提交回复
热议问题