Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Identify which script sets a cookie

Tags:

cookies

I need to create a list of cookies and their sources. Is there any way to understand from which script particular cookie comes from? For example, '_ga' cookie is definitely set by some of the google analytics script, but is it possible to identify which script exactly?

like image 684
Alexander Kleshchukevich Avatar asked Jul 23 '18 12:07

Alexander Kleshchukevich


People also ask

How do I know what cookies are set?

For Google Chrome go to View > Developer > Developer Tools or CMD + ALT + I on Mac or F12 on Windows. ‍Now open the Application tab and check the cookies for each domain.

Is a script a cookie?

A quick primer: cookies and scripts Cookies can be useful for things like recording if a user has logged into a website or not. To find out more about cookies, visit www.allaboutcookies.org. Scripts are small computer programs embedded within web pages that give those pages extra functionality.

What is cookies in web Script?

An HTTP cookie (web cookie, browser cookie) is a small piece of data that a server sends to a user's web browser. The browser may store the cookie and send it back to the same server with later requests.

Are cookies set automatically?

Cookies are usually set by a web-server using the response Set-Cookie HTTP-header. Then, the browser automatically adds them to (almost) every request to the same domain using the Cookie HTTP-header.


1 Answers

Some of the cookies are set by ajax-responses (you can find such cookies in Chrome Dev Tools -> Network tab and make a search with string 'set-cookie:').

As for the rest, I took a code snippet from here Breaking JavaScript execution always when cookie is set but instead of debugging I'm calling console.trace() function, which actually shows functions and their sources. That's it!

like image 131
Alexander Kleshchukevich Avatar answered Oct 09 '22 13:10

Alexander Kleshchukevich