P
P
Pavel2021-07-09 13:46:48
WordPress
Pavel, 2021-07-09 13:46:48

How to extend the lifetime of a REST Cookie?

The site has a part where there is a small SPA and it works on custom REST API routes. And the problem is that if the user is idle for some time and does not send requests, then in the end, once again, when accessing the api, he will receive 403, rest_cookie_invalid. Helps to refresh the page. How to deal with it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
SergeyGrigorev, 2013-10-22
@SergeyGrigorev

You enclose words in brackets like this (\w+)\[(\w+)\](\w+) and then you get 3 groups, each of which has one word from your example

M
Mikhail Priver, 2013-10-22
@mpriver

For example, like this: ([^\[]+)\[([^\]]+)\](.+)
More:

  1. ([^\[]+)- any character except " ["
  2. \[- actually " ["
  3. ([^\]]+)- any character except " ]"
  4. \]- closing bracket
  5. (.+)- all the rest

Parentheses are needed for grouping, i.e. at the output you will get 3 groups, each will have a "word".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question