Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8765271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:14:23+00:00 2026-06-13T16:14:23+00:00

I want to get the id cookie that Google issues when you opt-in at

  • 0

I want to get the id cookie that Google issues when you opt-in at the ads settings page (if you’re already accepting target advertisement, you must opt out first to see the page to which I am referring).

I’ve found that, in order to get this cookie, you have to perform an HTTP GET to the action URL in the form that is in this page. The problem is that this URL contains a hash that changes for every new HTTP connection so, first, I must go to this page and get this URL and, then, perform the GET to the URL.

I’m using HttpComponents to get http://www.google.com/ads/preferences but when I parse the contents with JSOUP there is only a script and no form can be found.

I’m afraid that this happens becauses contents are loaded dynamically using some sort of timeout… Does anyone know a workaround for this?

EDIT: by the way, the code that I use by now is:

        HttpClient httpclient = new DefaultHttpClient();

        // Create a local instance of cookie store
        CookieStore cookieStore = new BasicCookieStore();
        // Bind custom cookie store to the local context
        ((AbstractHttpClient) httpclient).setCookieStore(cookieStore);
        CookieSpecFactory csf = new CookieSpecFactory() {
            public CookieSpec newInstance(HttpParams params) {
                return new BrowserCompatSpec() {
                    @Override
                    public void validate(Cookie cookie, CookieOrigin origin)
                            throws MalformedCookieException {
                        // Allow all cookies
                        System.out.println("Allowed cookie: " + cookie.getName() + " "
                                + cookie.getValue() + " " + cookie.getPath());
                    }
                };
            }
        };
        ((AbstractHttpClient) httpclient).getCookieSpecs().register("EASY", csf);

        // Create local HTTP context
        HttpContext localContext = new BasicHttpContext();
        // Bind custom cookie store to the local context
        localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
        HttpGet httpget = new HttpGet(doubleClickURL);
        // Override the default policy for this request
        httpclient.getParams().setParameter(
                ClientPNames.COOKIE_POLICY, "EASY"); 

        // Pass local context as a parameter
        HttpResponse response = httpclient.execute(httpget, localContext);

        HttpEntity entity = response.getEntity();

        if (entity != null) {                               
                InputStream instream = entity.getContent();

                BufferedReader reader = new BufferedReader(
                        new InputStreamReader(instream));
                instream.close();
                // Find action attribute of form
                Document document = Jsoup.parse(reader.readLine());
                Element form = document.select("form").first();         
                String optinURL = form.attr("action");
                URL connection = new URL(optinURL);
                // ... get id Cookie

        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T16:14:24+00:00Added an answer on June 13, 2026 at 4:14 pm

    Finally I found it! I found the following site describing the doubleclick cookie protocol:

    Privacy Advisory

    Then, is as easy as setting a cookie in that domain with name id and value A. Then make an HTTP request to http://www.google.com/ads/preferences and they’ll set a correct ID value.

    It is a very specific question but I hope that serves to future viewers.

    By the way, I found that amazon.com is for example a member of the Ad-sense Network. An HTTP request to doubleclick is sent by means of script in the main page to:

    http://ad.doubleclick.net/adj/amzn.us.gw.atf

    There you can find a script that seems the actual code to give you the id cookie. Nevertheless, if you access this with the cookie with value A it will set the id of doubleclick.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want users that visit my website using their phone to get a cookie
I want get all of the Geom objects that are related to a certain
Basically I want get data I already have accessed from javascript and passing it
I want to fetch a web page from a ASP.NET site that is only
I want to fetch a web page from a ASP.NET site that is only
I want to get active window's cookie information in an extension built with the
I want to create a php cookie that stores the username and the userid.
I want to get the session cookie of a website. Unfortunately the Set-Cookie-Header doesn't
I want to set a cookie whenever a user visits a page, so not
I want get the time used for a case so I can create an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.