Skip to content

Commit

Permalink
feat: browser level cookies API (#13316)
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Rudenko <[email protected]>
  • Loading branch information
Kle0s and OrKoN authored Nov 26, 2024
1 parent 0c7136f commit 43dec3b
Show file tree
Hide file tree
Showing 23 changed files with 928 additions and 31 deletions.
16 changes: 16 additions & 0 deletions docs/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,13 @@ Description
</td></tr>
<tr><td>

<span id="convertcookiespartitionkeyfrompuppeteertocdp">[convertCookiesPartitionKeyFromPuppeteerToCdp(partitionKey)](./puppeteer.convertcookiespartitionkeyfrompuppeteertocdp.md)</span>

</td><td>

</td></tr>
<tr><td>

<span id="defaultargs">[defaultArgs(options)](./puppeteer.defaultargs.md)</span>

</td><td>
Expand Down Expand Up @@ -782,6 +789,15 @@ Launcher options that only apply to Chrome.
</td></tr>
<tr><td>

<span id="chromecookiepartitionkey">[ChromeCookiePartitionKey](./puppeteer.chromecookiepartitionkey.md)</span>

</td><td>

Represents a cookie partition key in Chrome.

</td></tr>
<tr><td>

<span id="chromeheadlessshellsettings">[ChromeHeadlessShellSettings](./puppeteer.chromeheadlessshellsettings.md)</span>

</td><td>
Expand Down
19 changes: 19 additions & 0 deletions docs/api/puppeteer.browser.cookies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
sidebar_label: Browser.cookies
---

# Browser.cookies() method

Returns all cookies in the default [BrowserContext](./puppeteer.browsercontext.md).

### Signature

```typescript
class Browser {
cookies(): Promise<Cookie[]>;
}
```

**Returns:**

Promise&lt;[Cookie](./puppeteer.cookie.md)\[\]&gt;
46 changes: 46 additions & 0 deletions docs/api/puppeteer.browser.deletecookie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
sidebar_label: Browser.deleteCookie
---

# Browser.deleteCookie() method

Removes cookies from the default [BrowserContext](./puppeteer.browsercontext.md).

### Signature

```typescript
class Browser {
deleteCookie(...cookies: Cookie[]): Promise<void>;
}
```

## Parameters

<table><thead><tr><th>

Parameter

</th><th>

Type

</th><th>

Description

</th></tr></thead>
<tbody><tr><td>

cookies

</td><td>

[Cookie](./puppeteer.cookie.md)\[\]

</td><td>

</td></tr>
</tbody></table>
**Returns:**

Promise&lt;void&gt;
33 changes: 33 additions & 0 deletions docs/api/puppeteer.browser.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,17 @@ Closes this [browser](./puppeteer.browser.md) and all associated [pages](./puppe
</td></tr>
<tr><td>
<span id="cookies">[cookies()](./puppeteer.browser.cookies.md)</span>
</td><td>
</td><td>
Returns all cookies in the default [BrowserContext](./puppeteer.browsercontext.md).
</td></tr>
<tr><td>
<span id="createbrowsercontext">[createBrowserContext(options)](./puppeteer.browser.createbrowsercontext.md)</span>
</td><td>
Expand Down Expand Up @@ -182,6 +193,17 @@ The default [browser context](./puppeteer.browsercontext.md) cannot be closed.
</td></tr>
<tr><td>
<span id="deletecookie">[deleteCookie(cookies)](./puppeteer.browser.deletecookie.md)</span>
</td><td>
</td><td>
Removes cookies from the default [BrowserContext](./puppeteer.browsercontext.md).
</td></tr>
<tr><td>
<span id="disconnect">[disconnect()](./puppeteer.browser.disconnect.md)</span>
</td><td>
Expand Down Expand Up @@ -249,6 +271,17 @@ Gets the associated [ChildProcess](https://nodejs.org/api/child_process.html#cla
</td></tr>
<tr><td>
<span id="setcookie">[setCookie(cookies)](./puppeteer.browser.setcookie.md)</span>
</td><td>
</td><td>
Sets cookies in the default [BrowserContext](./puppeteer.browsercontext.md).
</td></tr>
<tr><td>
<span id="target">[target()](./puppeteer.browser.target.md)</span>
</td><td>
Expand Down
46 changes: 46 additions & 0 deletions docs/api/puppeteer.browser.setcookie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
sidebar_label: Browser.setCookie
---

# Browser.setCookie() method

Sets cookies in the default [BrowserContext](./puppeteer.browsercontext.md).

### Signature

```typescript
class Browser {
setCookie(...cookies: Cookie[]): Promise<void>;
}
```

## Parameters

<table><thead><tr><th>

Parameter

</th><th>

Type

</th><th>

Description

</th></tr></thead>
<tbody><tr><td>

cookies

</td><td>

[Cookie](./puppeteer.cookie.md)\[\]

</td><td>

</td></tr>
</tbody></table>
**Returns:**

Promise&lt;void&gt;
19 changes: 19 additions & 0 deletions docs/api/puppeteer.browsercontext.cookies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
sidebar_label: BrowserContext.cookies
---

# BrowserContext.cookies() method

Gets all cookies in the browser context.

### Signature

```typescript
class BrowserContext {
abstract cookies(): Promise<Cookie[]>;
}
```

**Returns:**

Promise&lt;[Cookie](./puppeteer.cookie.md)\[\]&gt;
48 changes: 48 additions & 0 deletions docs/api/puppeteer.browsercontext.deletecookie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
sidebar_label: BrowserContext.deleteCookie
---

# BrowserContext.deleteCookie() method

Removes cookie in the browser context

### Signature

```typescript
class BrowserContext {
deleteCookie(...cookies: Cookie[]): Promise<void>;
}
```

## Parameters

<table><thead><tr><th>

Parameter

</th><th>

Type

</th><th>

Description

</th></tr></thead>
<tbody><tr><td>

cookies

</td><td>

[Cookie](./puppeteer.cookie.md)\[\]

</td><td>

[cookie](./puppeteer.cookie.md) to remove

</td></tr>
</tbody></table>
**Returns:**

Promise&lt;void&gt;
33 changes: 33 additions & 0 deletions docs/api/puppeteer.browsercontext.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,28 @@ The [default browser context](./puppeteer.browser.defaultbrowsercontext.md) cann
</td></tr>
<tr><td>
<span id="cookies">[cookies()](./puppeteer.browsercontext.cookies.md)</span>
</td><td>
</td><td>
Gets all cookies in the browser context.
</td></tr>
<tr><td>
<span id="deletecookie">[deleteCookie(cookies)](./puppeteer.browsercontext.deletecookie.md)</span>
</td><td>
</td><td>
Removes cookie in the browser context
</td></tr>
<tr><td>
<span id="newpage">[newPage()](./puppeteer.browsercontext.newpage.md)</span>
</td><td>
Expand Down Expand Up @@ -187,6 +209,17 @@ Non-visible [pages](./puppeteer.page.md), such as `"background_page"`, will not
</td></tr>
<tr><td>
<span id="setcookie">[setCookie(cookies)](./puppeteer.browsercontext.setcookie.md)</span>
</td><td>
</td><td>
Sets a cookie in the browser context.
</td></tr>
<tr><td>
<span id="targets">[targets()](./puppeteer.browsercontext.targets.md)</span>
</td><td>
Expand Down
48 changes: 48 additions & 0 deletions docs/api/puppeteer.browsercontext.setcookie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
sidebar_label: BrowserContext.setCookie
---

# BrowserContext.setCookie() method

Sets a cookie in the browser context.

### Signature

```typescript
class BrowserContext {
abstract setCookie(...cookies: Cookie[]): Promise<void>;
}
```

## Parameters

<table><thead><tr><th>

Parameter

</th><th>

Type

</th><th>

Description

</th></tr></thead>
<tbody><tr><td>

cookies

</td><td>

[Cookie](./puppeteer.cookie.md)\[\]

</td><td>

[cookie](./puppeteer.cookie.md) to set

</td></tr>
</tbody></table>
**Returns:**

Promise&lt;void&gt;
Loading

0 comments on commit 43dec3b

Please sign in to comment.