var ses = session.fromPartition('persist:name');
```
-### Instance Events
+## Instance Events
The following events are available on instances of `Session`:
-#### Event: 'will-download'
+### Event: 'will-download'
* `event` Event
* `item` [DownloadItem](download-item.md)
});
```
-### Instance Methods
+## Instance Methods
The following methods are available on instances of `Session`:
-#### `ses.cookies`
+### `session.cookies`
The `cookies` gives you ability to query and modify cookies. For example:
});
```
-#### `ses.cookies.get(filter, callback)`
+### `session.cookies.get(filter, callback)`
* `filter` Object
* `url` String (optional) - Retrieves cookies which are associated with
the number of seconds since the UNIX epoch. Not provided for session
cookies.
-#### `ses.cookies.set(details, callback)`
+### `session.cookies.set(details, callback)`
* `details` Object
* `url` String - Retrieves cookies which are associated with `url`
Sets the cookie with `details`, `callback` will be called with `callback(error)`
on complete.
-#### `ses.cookies.remove(url, name, callback)`
+### `session.cookies.remove(url, name, callback)`
* `url` String - The URL associated with the cookie.
* `name` String - The name of cookie to remove.
Removes the cookies matching `url` and `name`, `callback` will called with
`callback()` on complete.
-#### `ses.getCacheSize(callback)`
+### `session.getCacheSize(callback)`
* `callback` Function
* `size` Integer - Cache size used in bytes.
Returns the session's current cache size.
-#### `ses.clearCache(callback)`
+### `session.clearCache(callback)`
* `callback` Function - Called when operation is done
Clears the session’s HTTP cache.
-#### `ses.clearStorageData([options, ]callback)`
+### `session.clearStorageData([options, ]callback)`
* `options` Object (optional)
* `origin` String - Should follow `window.location.origin`’s representation
Clears the data of web storages.
-#### `ses.flushStorageData()`
+### `session.flushStorageData()`
Writes any unwritten DOMStorage data to disk.
-#### `ses.setProxy(config, callback)`
+### `session.setProxy(config, callback)`
* `config` Object
* `pacScript` String - The URL associated with the PAC file.
* `http=foopy;socks=foopy2` - Use HTTP proxy `foopy` for http URLs, and use
`socks4://foopy2` for all other URLs.
-### `ses.resolveProxy(url, callback)`
+### `session.resolveProxy(url, callback)`
* `url` URL
* `callback` Function
Resolves the proxy information for `url`. The `callback` will be called with
`callback(proxy)` when the request is performed.
-#### `ses.setDownloadPath(path)`
+### `session.setDownloadPath(path)`
* `path` String - The download location
Sets download saving directory. By default, the download directory will be the
`Downloads` under the respective app folder.
-#### `ses.enableNetworkEmulation(options)`
+### `session.enableNetworkEmulation(options)`
* `options` Object
* `offline` Boolean - Whether to emulate network outage.
window.webContents.session.enableNetworkEmulation({offline: true});
```
-#### `ses.disableNetworkEmulation()`
+### `session.disableNetworkEmulation()`
Disables any network emulation already active for the `session`. Resets to
the original network configuration.
-#### `ses.setCertificateVerifyProc(proc)`
+### `session.setCertificateVerifyProc(proc)`
* `proc` Function
});
```
-#### `ses.setPermissionRequestHandler(handler)`
+### `session.setPermissionRequestHandler(handler)`
* `handler` Function
* `webContents` Object - [WebContents](web-contents.md) requesting the permission.
});
```
-#### `ses.clearHostResolverCache([callback])`
+### `session.clearHostResolverCache([callback])`
* `callback` Function (optional) - Called when operation is done.
Clears the host resolver cache.
-#### `ses.webRequest`
+### `session.webRequest`
The `webRequest` API set allows to intercept and modify contents of a request at
various stages of its lifetime.
});
```
-#### `ses.webRequest.onBeforeRequest([filter, ]listener)`
+### `session.webRequest.onBeforeRequest([filter, ]listener)`
* `filter` Object
* `listener` Function
* `redirectURL` String (optional) - The original request is prevented from
being sent or completed, and is instead redirected to the given URL.
-#### `ses.webRequest.onBeforeSendHeaders([filter, ]listener)`
+### `session.webRequest.onBeforeSendHeaders([filter, ]listener)`
* `filter` Object
* `listener` Function
* `requestHeaders` Object (optional) - When provided, request will be made
with these headers.
-#### `ses.webRequest.onSendHeaders([filter, ]listener)`
+### `session.webRequest.onSendHeaders([filter, ]listener)`
* `filter` Object
* `listener` Function
* `timestamp` Double
* `requestHeaders` Object
-#### `ses.webRequest.onHeadersReceived([filter,] listener)`
+### `session.webRequest.onHeadersReceived([filter,] listener)`
* `filter` Object
* `listener` Function
* `statusLine` String (optional) - Should be provided when overriding `responseHeaders`
to change header status otherwise original response header's status will be used.
-#### `ses.webRequest.onResponseStarted([filter, ]listener)`
+### `session.webRequest.onResponseStarted([filter, ]listener)`
* `filter` Object
* `listener` Function
* `statusCode` Integer
* `statusLine` String
-#### `ses.webRequest.onBeforeRedirect([filter, ]listener)`
+### `session.webRequest.onBeforeRedirect([filter, ]listener)`
* `filter` Object
* `listener` Function
* `fromCache` Boolean
* `responseHeaders` Object
-#### `ses.webRequest.onCompleted([filter, ]listener)`
+### `session.webRequest.onCompleted([filter, ]listener)`
* `filter` Object
* `listener` Function
* `statusCode` Integer
* `statusLine` String
-#### `ses.webRequest.onErrorOccurred([filter, ]listener)`
+### `session.webRequest.onErrorOccurred([filter, ]listener)`
* `filter` Object
* `listener` Function