Hello everyone, i am in some kind of testing stage where i want to test some security flaws on websites/browsers with the cookies.
I want to generate google cookies with a different time period. (older than 2 months).
Firstly I will try to integrate into the browser via JS
Secondly i will try to integrate them manually via the browser
Thirdly i will try to integrate them via chrome plugin called EditThisCookie
Forth i will try to integrate via chromium automated browser.
I will post the updates here as i am getting results from them.
If anyone with the knowledge can help me how to generate this kind of real cookies please reply.

Here is a google cookie from my browser taken with the plugin EditThisCookie

[
{
    "domain": ".google.com",
    "expirationDate": 1720692511.866038,
    "hostOnly": false,
    "httpOnly": false,
    "name": "__Secure-1PAPISID",
    "path": "/",
    "sameSite": "unspecified",
    "secure": true,
    "session": false,
    "storeId": "0",
    "value": "jwwodBB_Lh0Hs7ZS/AC4Ex9QlednbpdGgQ",
    "id": 1
},
{
    "domain": ".google.com",
    "expirationDate": 1720692511.865889,
    "hostOnly": false,
    "httpOnly": true,
    "name": "__Secure-1PSID",
    "path": "/",
    "sameSite": "unspecified",
    "secure": true,
    "session": false,
    "storeId": "0",
    "value": "XQjJqisiNRlJO_VKG3ZJM2C2rx_IME4xK-WcnU1tb4wpgUAlwOr34jllGr6pPvSdox7iQA.",
    "id": 2
},
{
    "domain": ".google.com",
    "expirationDate": 1717692417.861374,
    "hostOnly": false,
    "httpOnly": true,
    "name": "__Secure-1PSIDCC",
    "path": "/",
    "sameSite": "unspecified",
    "secure": true,
    "session": false,
    "storeId": "0",
    "value": "AP8dLtzow1zA6ZFmHY6wJ4_cUZ0-VqJvipkRP4a_DdORG4jwJ_rD-US9F9CGQxssZ-TgNRa4Nw",
    "id": 3
},
{
    "domain": ".google.com",
    "expirationDate": 1717692032.138858,
    "hostOnly": false,
    "httpOnly": true,
    "name": "__Secure-1PSIDTS",
    "path": "/",
    "sameSite": "unspecified",
    "secure": true,
    "session": false,
    "storeId": "0",
    "value": "sidts-CjEBLFra0pi602FUuDQKuuGJ9hYiBaOo75-qG7xARkL1xHY7CvNGqYWLysWOesogZD0FEAA",
    "id": 4
},
{
    "domain": ".google.com",
    "expirationDate": 1720692511.866049,
    "hostOnly": false,
    "httpOnly": false,
    "name": "__Secure-3PAPISID",
    "path": "/",
    "sameSite": "no_restriction",
    "secure": true,
    "session": false,
    "storeId": "0",
    "value": "jwwodBB_Lh0Hs7ZS/AC4Ex9QlednbpdGgQ",
    "id": 5
},
{
    "domain": ".google.com",
    "expirationDate": 1720692511.86594,
    "hostOnly": false,
    "httpOnly": true,
    "name": "__Secure-3PSID",
    "path": "/",
    "sameSite": "no_restriction",
    "secure": true,
    "session": false,
    "storeId": "0",
    "value": "XQjJqisiNRlJO_VKG3ZJM2C2rx_IME4xK-WcnU1tb4wpgUAleOcsDwYZuVAELT4ra65Vgw.",
    "id": 6
},
{
    "domain": ".google.com",
    "expirationDate": 1717692417.86144,
    "hostOnly": false,
    "httpOnly": true,
    "name": "__Secure-3PSIDCC",
    "path": "/",
    "sameSite": "no_restriction",
    "secure": true,
    "session": false,
    "storeId": "0",
    "value": "AP8dLtxT_Rw_UCObHbCi4Jab87loYlTcYbvqglhQ9Auncos-3jJxI8lSYGmp2mfLIJHs41sTdQ",
    "id": 7
},
{
    "domain": ".google.com",
    "expirationDate": 1717692032.138932,
    "hostOnly": false,
    "httpOnly": true,
    "name": "__Secure-3PSIDTS",
    "path": "/",
    "sameSite": "no_restriction",
    "secure": true,
    "session": false,
    "storeId": "0",
    "value": "sidts-CjEBLFra0pi602FUuDQKuuGJ9hYiBaOo75-qG7xARkL1xHY7CvNGqYWLysWOesogZD0FEAA",
    "id": 8
},
{
    "domain": ".google.com",
    "expirationDate": 1688748416.96123,
    "hostOnly": false,
    "httpOnly": false,
    "name": "1P_JAR",
    "path": "/",
    "sameSite": "no_restriction",
    "secure": true,
    "session": false,
    "storeId": "0",
    "value": "2023-06-07-16",
    "id": 9
},
{
    "domain": ".google.com",
    "expirationDate": 1701708416.266443,
    "hostOnly": false,
    "httpOnly": true,
    "name": "AEC",
    "path": "/",
    "sameSite": "lax",
    "secure": true,
    "session": false,
    "storeId": "0",
    "value": "AUEFqZdpg1oWpE5K6nanbU2IN9KaY4Y9-y1S5oFKZ77gJysUxrvjk60BEQ",
    "id": 10
},
{
    "domain": ".google.com",
    "expirationDate": 1720692511.866016,
    "hostOnly": false,
    "httpOnly": false,
    "name": "APISID",
    "path": "/",
    "sameSite": "unspecified",
    "secure": false,
    "session": false,
    "storeId": "0",
    "value": "aQOjK6fOGGrrcF4e/Appce7TNc6obXcejp",
    "id": 11
},
{
    "domain": ".google.com",
    "expirationDate": 1720692511.865996,
    "hostOnly": false,
    "httpOnly": true,
    "name": "HSID",
    "path": "/",
    "sameSite": "unspecified",
    "secure": false,
    "session": false,
    "storeId": "0",
    "value": "ApZ9wo5erf3tfsD6P",
    "id": 12
},
{
    "domain": ".google.com",
    "expirationDate": 1701967616.788204,
    "hostOnly": false,
    "httpOnly": true,
    "name": "NID",
    "path": "/",
    "sameSite": "no_restriction",
    "secure": true,
    "session": false,
    "storeId": "0",
    "value": "511=V2B5r7ZprujY5Bf3zJUj5jTFZClpU-ZpRjeAK3l6X_LleHkzV5oYzFI4KiUqtoD2EBXuyHZvOGZ37FJ7URe1JPJa47UDpLiggjCLwT89fRTMbok2Bq4b20GSKU7lOp1o9q51grGkBUT2vtYVmfoonEhDWY984dRkTbn1wmgQ1QdH_zOIY_O4c9Cb7nU80hAg3iffZHK5VUYpNLdS4VQuBXMvHkEKf_FdeBcPagcj_3kRQgnbcfU15xYZGi0",
    "id": 13
},
{
    "domain": ".google.com",
    "expirationDate": 1720692511.866027,
    "hostOnly": false,
    "httpOnly": false,
    "name": "SAPISID",
    "path": "/",
    "sameSite": "unspecified",
    "secure": true,
    "session": false,
    "storeId": "0",
    "value": "jwwodBB_Lh0Hs7ZS/AC4Ex9QlednbpdGgQ",
    "id": 14
},
{
    "domain": ".google.com",
    "expirationDate": 1701708416.266407,
    "hostOnly": false,
    "httpOnly": false,
    "name": "SEARCH_SAMESITE",
    "path": "/",
    "sameSite": "strict",
    "secure": false,
    "session": false,
    "storeId": "0",
    "value": "CgQIu5gB",
    "id": 15
},
{
    "domain": ".google.com",
    "expirationDate": 1720692511.865815,
    "hostOnly": false,
    "httpOnly": false,
    "name": "SID",
    "path": "/",
    "sameSite": "unspecified",
    "secure": false,
    "session": false,
    "storeId": "0",
    "value": "XQjJqisiNRlJO_VKG3ZJM2C2rx_IME4xK-WcnU1tb4wpgUAlSRPHZSWJDY0gNCILO7Bn0w.",
    "id": 16
},
{
    "domain": ".google.com",
    "expirationDate": 1717692417.861301,
    "hostOnly": false,
    "httpOnly": false,
    "name": "SIDCC",
    "path": "/",
    "sameSite": "unspecified",
    "secure": false,
    "session": false,
    "storeId": "0",
    "value": "AP8dLtxD7XpF_-Z2RMtpZmEg6t8s-ySFPt5VxzQIeIMyveqLH8Qvp2E38lKLi7oqvU9qY-UV2dE",
    "id": 17
},
{
    "domain": ".google.com",
    "expirationDate": 1720692511.866006,
    "hostOnly": false,
    "httpOnly": true,
    "name": "SSID",
    "path": "/",
    "sameSite": "unspecified",
    "secure": true,
    "session": false,
    "storeId": "0",
    "value": "AlQ5PUXgQYyxojeTF",
    "id": 18
}
]
AndreRet commented: Not sure what your question is? +15

@AndreRat i want to generate cookies from google without using different browsers. Is there a way to generate them without browsers?

Generating cookies from Google without using a browser is not possible. Cookies are small text files that are stored on your computer by websites you visit through your web browser. They are used to store information about your browsing activity, preferences, and login sessions etc.

To generate cookies, you need to interact with Google services through a web browser. This is because cookies are managed by the browser, and the browser handles the communication between your computer and the website's server.

If you are trying to access or manipulate cookies for a specific purpose, I need more details about your goal, and I'll be happy to help.

Thanks for your reply @AndreRat also are they are location based too or the location doesnt matter? For example i need USA Google cookies. And if i use same browser to generate google cookies each time with cleaning the browser history/cache/data will be that possible to generate different cookies? Also my purpose is when user visit my site i want to detect his browser google cookies (does he have them or not) and check whether they are real or not?
I am doing this to straighten my website security (if user is bot or not) and also test some other security flaws along the way

Still relevant to the original question -

In terms of location-based data, your site can use cookies to store information such as the user's preferred language, currency, or regional settings. This allows your site to specify it's content and operations based on the user's location.

Also, your site may use cookies to track the user's geographical location for various purposes i.e., an e-commerce site might use location-based cookies to display relevant products or services available in the user's area etc.

You need to note however that the use of cookies for location-based data may require the user's consent.

The other questions you asked is not relevant to this post, please open a new post PER question as it might lead to an endless discussion of various questions and answers which will be confusing for future readers.

The thing is i don't see any value that is named "location" so i am a little bit confused how they can detect the user location based on cookies?
I have used USA proxies and visited google.com but still didnt noticed any difference in the structure of the cookies.

"domain": ".google.com",
    "expirationDate": 1720692511.865996,
    "hostOnly": false,
    "httpOnly": true,
    "name": "HSID",
    "path": "/",
    "sameSite": "unspecified",
    "secure": false,
    "session": false,
    "storeId": "0",
    "value": "ApZ9wo5erf3tfsD6P",
    "id": 12

There is no 'location' variable/value available, you need to use location API's to get their current location and save it to either your database or a cookie. This is quite dangerous though leading to banning of your accounts.

Attempting to detect a user's location without their consent or using unauthorized means is a violation of privacy and potentially illegal in most countries including USA.

If you have a legitimate reason to obtain a user's location, such as providing relevant localized content or improving user experience, it's important to obtain their consent and follow applicable privacy laws and regulations.

To obtain user consent for accessing their location and storing it in a cookie, you can follow these basic guidelines -

Provide clear and transparent information explaining to the user why you need their location information and how it will be used to enhance their experience.

Use a cookie consent banner or pop-up that explicitly asks for their consent to collect and store their location data in a cookie. The banner should provide an option for the user to either accept or decline.

Provide granular options for users to select the specific types of data they want to share for example the choice to share their precise location or a more general regional location.

Give the user an opt-in approach where the user actively selects their consent instead of pre-selecting the consent by default. This ensures that the user actively agrees to share their location.

Allow users to easily withdraw their consent at any time and delete their location data if they choose to do so.

Have a comprehensive and easily accessible privacy policy page/document that outlines the specifics of data collection, storage, and usage. Make sure it is clear and compliant with relevant laws and regulations.

You can read up more on this - Is It Illegal To Track Cookies
Cookie walls or forced consent
All about cookies

Thats a well written info about cookies but that's not my purpose. I posted this thread with intention someone to help me generate google cookies and integrate into the Chrome browser whether through plugin or directly in the browser it self. I will do my test afterwards when i do that step first. So i see this thread is getting too long i guess i should mark it "solved".

It seems that the question is not yet answered, my apologies. To create the cookies as you requested (Normally I will not supply full code without effort from the poster shown), you can do the following. This is only a basic example and you need to read and understand the code, it should however run fine in your page...

First, create your browser page (php, html) with cookie and to get user consent -

<!-- index.html -->
<!DOCTYPE html>
<html>
<head>
  <title>Cookie Example</title>
  <script src="script.js"></script> <!-- Include the JavaScript file -->
</head>
<body>
  <h1>Cookie Example</h1>

  <div id="consentPrompt">
    <p>Please provide your consent to save the cookie:</p>
    <button onclick="giveConsent()">Give Consent</button>
  </div>

  <script>
    function giveConsent() {
      // Call the createCookie function with the desired values
      createCookie(
        '__Secure-1PAPISID',
        'jwwodBB_Lh0Hs7ZS/AC4Ex9QlednbpdGgQ',
        1720692511.866038,
        '.google.com',
        '/',
        true,
        false,
        'unspecified'
      );

      // Hide the consent prompt after giving consent
      document.getElementById('consentPrompt').style.display = 'none';
    }
  </script>
</body>
</html>

Secondly, we will create the JavaScript file named cookiescript.js and save it in the same directory as your PHP/HTML file -

// script.js
    function createCookie(name, value, expirationDate, domain, path, secure, httpOnly, sameSite) {
      // Prepare the cookie string
      let cookieString = name + '=' + value;

      // Convert expirationDate to a timestamp (2 months in the past)
      const expirationTimestamp = new Date(expirationDate).getTime() - (2 * 30 * 24 * 60 * 60 * 1000);

      // Append optional parameters
      cookieString += '; expires=' + new Date(expirationTimestamp).toUTCString();
      cookieString += '; domain=' + domain;
      cookieString += '; path=' + path;
      if (secure) {
        cookieString += '; secure';
      }
      if (httpOnly) {
        cookieString += '; httponly';
      }
      cookieString += '; samesite=' + sameSite;

      // Set the cookie
      document.cookie = cookieString;
    }

    // Example usage
const cookie = {
  "domain": ".google.com",
  "expirationDate": 1720692511.866038,
  "hostOnly": false,
  "httpOnly": false,
  "name": "__Secure-1PAPISID",
  "path": "/",
  "sameSite": "unspecified",
  "secure": true,
  "session": false,
  "storeId": "0",
  "value": "jwwodBB_Lh0Hs7ZS/AC4Ex9QlednbpdGgQ",
  "id": 1,
  "location": "New York"
};

createCookie(
  cookie.name,
  cookie.value,
  cookie.expirationDate,
  cookie.domain,
  cookie.path,
  cookie.secure,
  cookie.httpOnly,
  cookie.sameSite
);

Thirdly, to get the user's location in JavaScript, you can use the Geolocation API provided by most modern web browsers (with all of the above security and consent measures in place) -

function getLocation(callback) {
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(
      function(position) {
        // Retrieve latitude and longitude
        const latitude = position.coords.latitude;
        const longitude = position.coords.longitude;

        // Call the callback function with the location data
        callback(latitude, longitude);
      },
      function(error) {
        // Handle error if geolocation retrieval fails
        console.log('Error retrieving location:', error);
        callback(null, null); // Pass null values to indicate failure
      }
    );
  } else {
    console.log('Geolocation is not supported by this browser.');
    callback(null, null); // Pass null values to indicate unsupported browser
  }
}

// Usage:
getLocation(function(latitude, longitude) {
  if (latitude && longitude) {
    const location = latitude + ', ' + longitude;
    console.log('Location:', location);

    // Use the obtained location value to set the cookie or perform other operations
  } else {
    console.log('Location could not be retrieved.');
  }
});

I trust this will be the answer you were looking for.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.