How to persist cookies between different casperjs processes?

844 views
Skip to first unread message

havy...@gmail.com

unread,
May 18, 2015, 4:58:00 AM5/18/15
to casp...@googlegroups.com

Hi, All,

Can anybody help me out of the problem? Thanks in advance!

When i start the worker casperjs I add the –cookies-file=cookies.txt.

casperjs --cookies-file=cookies.txt login.js

So after that, I have saved the login cookies to cookies.txt. But how can i load this cookie file for next casperjs process? I want to use the cookie rather than do login again.

My cookies.txt file looks exactly like this:

cookies="@Variant(\0\0\0\x7f\0\0\0\x16QList<QNetworkCookie>\0\0\0\0\x1\0\0\0\xf\0\0\0]nts_mail_user=mycasperjs:-1:1; expires=Sat, 30-Jan-2100 16:00:00 GMT; domain=.126.com; path=/\0\0\0\xbbP_INFO=mycas...@126.com|1431933027|0|mail126|00&99|zhj&1431932965&mail126#zhj&330100#10#0#0|&0|mail126|mycas...@126.com; expires=Tue, 17-May-2016 07:10:26 GMT; domain=.126.com; path=/\0\0\0Mlocale=\"\"; expires=Thu, 15-May-2025 07:10:28 GMT; domain=mail.126.com; path=/\0\0\0\xbbP_INFO=mycas...@126.com|1431933027|0|mail126|00&99|zhj&1431932965&mail126#zhj&330100#10#0#0|&0|mail126|mycas...@126.com; expires=Tue, 17-May-2016 03:10:29 GMT; domain=.163.com; path=/\0\0\0MProvince=0571; expires=Mon, 01-Jun-2015 07:10:29 GMT; domain=.163.com; path=/\0\0\0ICity=0571; expires=Mon, 01-Jun-2015 07:10:29 GMT; domain=.163.com; path=/\0\0\0\x66MailMasterPopupTips=1431932894808; expires=Mon, 25-May-2015 07:08:14 GMT; domain=.mail.126.com; path=/\0\0\0\x82__utma=57883948.1309700131.1431932896.1431932896.1431932896.1; expires=Wed, 17-May-2017 07:08:15 GMT; domain=.web.yixin.im; path=/\0\0\0\x64__utmb=57883948.1.10.1431932896; expires=Mon, 18-May-2015 07:38:15 GMT; domain=.web.yixin.im; path=/\0\0\0\x91__utmz=57883948.1431932896.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); expires=Mon, 16-Nov-2015 19:08:15 GMT; domain=.web.yixin.im; path=/\0\0\0husertrack=ezq0alVZkGl+SSDsRooIAg==; expires=Tue, 17-May-2016 07:10:33 GMT; domain=.music.163.com; path=/\0\0\0UBOX_DISABLE=true; expires=Mon, 18-May-2015 08:10:33 GMT; domain=music.163.com; path=/\0\0\x1]JSESSIONID-WYYY=7c6d8edcabae0439d9d8970fb375a5e8b43dab3f48e6f20c78065a383ce654070da1a70cbd887c7de9f34462e084a5a91bdcfd92ba64de217c4bcaaa703da799277d1e865f89537e5c8c9e3b0fe662900f0a0b6a34d68e423048303a3443344ecd08115f5cc9cc756376857f58a1824cbda12fcb7d6b45d0638f2d3a0ada24d1a6c9b8a7; expires=Mon, 15-Jun-2015 07:08:18 GMT; domain=music.163.com; path=/\0\0\x1\xec\x66irstentry=%2FnewNotice.do%3FX-From-ISP%3D2%26sid%3DnAiVXOXsgPxaLXWwgWssdLeGweIYsDzD%26uid%3Dmycasperjs%40126.com%26host%3Dmail.126.com%26ver%3Djs6%26fontface%3Dyahei%26style%3D7%26skin%3Dfreshgreen%26color%3D138144%26email%3Dmycasperjs%40126.com%26from%3Dmailjs6%26callback%3Dnetease.mail.base.Ajax.padding851847563810|http%3A%2F%2Fmail.126.com%2Fjs6%2Fmain.jsp%3Fsid%3DnAiVXOXsgPxaLXWwgWssdLeGweIYsDzD%26df%3Dmail126_letter; expires=Tue, 19-May-2015 07:10:34 GMT; domain=.lofter.com; path=/\0\0\0\x65usertrack=ZUcIhlVZkGqjFX2tGVEJAg==; expires=Tue, 17-May-2016 07:10:34 GMT; domain=.lofter.com; path=/)"

dani...@gmail.com

unread,
Jun 3, 2015, 2:43:02 AM6/3/15
to casp...@googlegroups.com
up


Gabe Misura

unread,
Jun 18, 2015, 12:06:58 AM6/18/15
to casp...@googlegroups.com
CasperJS is based on PhantomJS, which has options to specify the location of your cookies.
  • --cookies-file=/path/to/cookies.txt specifies the file name to store the persistent Cookies.

On Monday, May 18, 2015 at 5:58:00 AM UTC-3, havy...@gmail.com wrote:

Hi, All,

Can anybody help me out of the problem? Thanks in advance!

When i start the worker casperjs I add the –cookies-file=cookies.txt.

casperjs --cookies-file=cookies.txt login.js

So after that, I have saved the login cookies to cookies.txt. But how can i load this cookie file for next casperjs process? I want to use the cookie rather than do login again.

My cookies.txt file looks exactly like this:

cookies="@Variant(\0\0\0\x7f\0\0\0\x16QList<QNetworkCookie>\0\0\0\0\x1\0\0\0\xf\0\0\0]nts_mail_user=mycasperjs:-1:1; expires=Sat, 30-Jan-2100 16:00:00 GMT; domain=.126.com; path=/\0\0\0\xbbP_INFO=mycasper...@126.com|1431933027|0|mail126|00&99|zhj&1431932965&mail126#zhj&330100#10#0#0|&0|mail126|mycas...@126.com; expires=Tue, 17-May-2016 07:10:26 GMT; domain=.126.com; path=/\0\0\0Mlocale=\"\"; expires=Thu, 15-May-2025 07:10:28 GMT; domain=mail.126.com; path=/\0\0\0\xbbP_INFO=mycasper...@126.com|1431933027|0|mail126|00&99|zhj&1431932965&mail126#zhj&330100#10#0#0|&0|mail126|mycas...@126.com; expires=Tue, 17-May-2016 03:10:29 GMT; domain=.163.com; path=/\0\0\0MProvince=0571; expires=Mon, 01-Jun-2015 07:10:29 GMT; domain=.163.com; path=/\0\0\0ICity=0571; expires=Mon, 01-Jun-2015 07:10:29 GMT; domain=.163.com; path=/\0\0\0\x66MailMasterPopupTips=1431932894808; expires=Mon, 25-May-2015 07:08:14 GMT; domain=.mail.126.com; path=/\0\0\0\x82__utma=57883948.1309700131.1431932896.1431932896.1431932896.1; expires=Wed, 17-May-2017 07:08:15 GMT; domain=.web.yixin.im; path=/\0\0\0\x64__utmb=57883948.1.10.1431932896; expires=Mon, 18-May-2015 07:38:15 GMT; domain=.web.yixin.im; path=/\0\0\0\x91__utmz=57883948.1431932896.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); expires=Mon, 16-Nov-2015 19:08:15 GMT; domain=.web.yixin.im; path=/\0\0\0husertrack=ezq0alVZkGl+SSDsRooIAg==; expires=Tue, 17-May-2016 07:10:33 GMT; domain=.music.163.com; path=/\0\0\0UBOX_DISABLE=true; expires=Mon, 18-May-2015 08:10:33 GMT; domain=music.163.com; path=/\0\0\x1]JSESSIONID-WYYY=7c6d8edcabae0439d9d8970fb375a5e8b43dab3f48e6f20c78065a383ce654070da1a70cbd887c7de9f34462e084a5a91bdcfd92ba64de217c4bcaaa703da799277d1e865f89537e5c8c9e3b0fe662900f0a0b6a34d68e423048303a3443344ecd08115f5cc9cc756376857f58a1824cbda12fcb7d6b45d0638f2d3a0ada24d1a6c9b8a7; expires=Mon, 15-Jun-2015 07:08:18 GMT; domain=music.163.com; path=/\0\0\x1\xec\x66irstentry=%2FnewNotice.do%3FX-From-ISP%3D2%26sid%3DnAiVXOXsgPxaLXWwgWssdLeGweIYsDzD%26uid%3Dmycasperjs%40126.com%26host%3Dmail.126.com%26ver%3Djs6%26fontface%3Dyahei%26style%3D7%26skin%3Dfreshgreen%26color%3D138144%26email%3Dmycasperjs%40126.com%26from%3Dmailjs6%26callback%3Dnetease.mail.base.Ajax.padding851847563810|http%3A%2F%2Fmail.126.com%2Fjs6%2Fmain.jsp%3Fsid%3DnAiVXOXsgPxaLXWwgWssdLeGweIYsDzD%26df%3Dmail126_letter; expires=Tue, 19-May-2015 07:10:34 GMT; domain=.lofter.com; path=/\0\0\0\x65usertrack=ZUcIhlVZkGqjFX2tGVEJAg==; expires=Tue, 17-May-2016 07:10:34 GMT; domain=.lofter.com; path=/)"

Reply all
Reply to author
Forward
0 new messages