const ses = session.fromPartition('persist:name');
```
-## 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`
+#### `ses.cookies`
The `cookies` gives you ability to query and modify cookies. For example:
});
```
-### `ses.cookies.get(filter, callback)`
+#### `ses.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)`
+#### `ses.cookies.set(details, callback)`
* `details` Object
* `url` String - The url to associate the cookie with.
Sets a cookie with `details`, `callback` will be called with `callback(error)`
on complete.
-### `ses.cookies.remove(url, name, callback)`
+#### `ses.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)`
+#### `ses.getCacheSize(callback)`
* `callback` Function
* `size` Integer - Cache size used in bytes.
Returns the session's current cache size.
-### `ses.clearCache(callback)`
+#### `ses.clearCache(callback)`
* `callback` Function - Called when operation is done
Clears the session’s HTTP cache.
-### `ses.clearStorageData([options, ]callback)`
+#### `ses.clearStorageData([options, ]callback)`
* `options` Object (optional)
* `origin` String - Should follow `window.location.origin`’s representation
Clears the data of web storages.
-### `ses.flushStorageData()`
+#### `ses.flushStorageData()`
Writes any unwritten DOMStorage data to disk.
-### `ses.setProxy(config, callback)`
+#### `ses.setProxy(config, callback)`
* `config` Object
* `pacScript` String - The URL associated with the PAC file.
Resolves the proxy information for `url`. The `callback` will be called with
`callback(proxy)` when the request is performed.
-### `ses.setDownloadPath(path)`
+#### `ses.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)`
+#### `ses.enableNetworkEmulation(options)`
* `options` Object
* `offline` Boolean - Whether to emulate network outage.
window.webContents.session.enableNetworkEmulation({offline: true});
```
-### `ses.disableNetworkEmulation()`
+#### `ses.disableNetworkEmulation()`
Disables any network emulation already active for the `session`. Resets to
the original network configuration.
-### `ses.setCertificateVerifyProc(proc)`
+#### `ses.setCertificateVerifyProc(proc)`
* `proc` Function
});
```
-### `ses.setPermissionRequestHandler(handler)`
+#### `ses.setPermissionRequestHandler(handler)`
* `handler` Function
* `webContents` Object - [WebContents](web-contents.md) requesting the permission.
});
```
-### `ses.clearHostResolverCache([callback])`
+#### `ses.clearHostResolverCache([callback])`
* `callback` Function (optional) - Called when operation is done.
Clears the host resolver cache.
-### `ses.allowNTLMCredentialsForDomains(domains)`
+#### `ses.allowNTLMCredentialsForDomains(domains)`
* `domains` String - A comma-seperated list of servers for which
integrated authentication is enabled.
session.defaultSession.allowNTLMCredentialsForDomains('*')
```
-### `ses.webRequest`
+#### `ses.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)`
+#### `ses.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)`
+#### `ses.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)`
+#### `ses.webRequest.onSendHeaders([filter, ]listener)`
* `filter` Object
* `listener` Function
* `timestamp` Double
* `requestHeaders` Object
-### `ses.webRequest.onHeadersReceived([filter,]listener)`
+#### `ses.webRequest.onHeadersReceived([filter,]listener)`
* `filter` Object
* `listener` Function
`responseHeaders` to change header status otherwise original response
header's status will be used.
-### `ses.webRequest.onResponseStarted([filter, ]listener)`
+#### `ses.webRequest.onResponseStarted([filter, ]listener)`
* `filter` Object
* `listener` Function
* `statusCode` Integer
* `statusLine` String
-### `ses.webRequest.onBeforeRedirect([filter, ]listener)`
+#### `ses.webRequest.onBeforeRedirect([filter, ]listener)`
* `filter` Object
* `listener` Function
* `fromCache` Boolean
* `responseHeaders` Object
-### `ses.webRequest.onCompleted([filter, ]listener)`
+#### `ses.webRequest.onCompleted([filter, ]listener)`
* `filter` Object
* `listener` Function
* `statusCode` Integer
* `statusLine` String
-### `ses.webRequest.onErrorOccurred([filter, ]listener)`
+#### `ses.webRequest.onErrorOccurred([filter, ]listener)`
* `filter` Object
* `listener` Function
* `fromCache` Boolean
* `error` String - The error description.
-### `ses.protocol`
+#### `ses.protocol`
Returns an instance of [protocol](protocol.md) module for this session.