简体   繁体   中英

Casperjs keep alive a login session

I'm trying to keep alive a login session, after 3 min of inactivity the user get disconnected.

The problem here is that most of cases the page is giving errors 502/504, so I want to send http get request every 20/30 secs without receive a response, just to leave a request and keep alive the session.

I want do it but at the same time that I make some stuff on the site, like scrapping, something like a new tab.

There's a way to make it works?

It depends on the site's content, but if it has any filter (as in show results filter) you could add a step in the script to change that every 20/30 secs, that means you "refresh" the content and the session stays alive.

Other way is adding a GET parameter on the url, let's say your page is http://www.example.com/infoineed . Add a step using thenOpen('http://www.example.com/infoineed?get=donothing') , this will somehow refresh the page but do nothing.

And finally you can use reload(),once again, this depends on the site you're working on.

Hope it helps, cheers!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM