good_evening
good_evening

Reputation: 21759

How to setup lots of cookies fast?

Let's say I have a string SID=hbewtrfdh;AAA_Cookie=1412f432g;OO=ferdbg4vw. I can set add them via some plugin, but I'd have to do that thrice. Is it possible to add cookies just by adding a string somewhere, probably via command line with javascript?

Upvotes: 1

Views: 69

Answers (1)

Sunny Patel
Sunny Patel

Reputation: 8077

Javascript cookies are as simple as setting the variable document.cookie.

Doing something similar to this should work for your scenario:

var cookies = "SID=hbewtrfdh;AAA_Cookie=1412f432g;OO=ferdbg4vw";
cookies = cookies.split(';');

for( var key in cookies ) {
    document.cookie = cookies[key] + "; path=/; max-age=60";
}

This would set up the 3 cookies all with the same path and max-age. Of course you can edit the extra parameters as you need.

MDN Docs

Upvotes: 1

Related Questions