localStorage vs sessionStorage vs cookies

localStorage and sessionStorage are both so-called WebStorages and features of HTML5. localStorage stores information as long as the user does not delete them. sessionStorage stores information as long as the session goes. Usually until the user closes the tab/browser. cookies are simply cookies, which are supported by older browsers and usually are a fallback for … Read more

How to do stateless (session-less) & cookie-less authentication?

Ah, I love these questions – maintaining a session without a session. I’ve seen multiple ways to do this during my stints during application assessments. One of the popular ways is the playing tennis way that you mentioned – sending the username and password in every request to authenticate the user. This, in my opinion, … Read more

How to set expiration date for cookie in AngularJS

This is possible in the 1.4.0 build of angular using the ngCookies module: https://docs.angularjs.org/api/ngCookies/service/$cookies angular.module(‘cookiesExample’, [‘ngCookies’]) .controller(‘ExampleController’, [‘$cookies’, function($cookies) { // Find tomorrow’s date. var expireDate = new Date(); expireDate.setDate(expireDate.getDate() + 1); // Setting a cookie $cookies.put(‘myFavorite’, ‘oatmeal’, {‘expires’: expireDate}); }]);

Using Python Requests: Sessions, Cookies, and POST

I don’t know how stubhub’s api works, but generally it should look like this: s = requests.Session() data = {“login”:”my_login”, “password”:”my_password”} url = “http://example.net/login” r = s.post(url, data=data) Now your session contains cookies provided by login form. To access cookies of this session simply use s.cookies Any further actions like another requests will have this … Read more

Scrapy – how to manage cookies/sessions

Three years later, I think this is exactly what you were looking for: http://doc.scrapy.org/en/latest/topics/downloader-middleware.html#std:reqmeta-cookiejar Just use something like this in your spider’s start_requests method: for i, url in enumerate(urls): yield scrapy.Request(“http://www.example.com”, meta={‘cookiejar’: i}, callback=self.parse_page) And remember that for subsequent requests, you need to explicitly reattach the cookiejar each time: def parse_page(self, response): # do some … Read more