# SyncGateway.SessionApi

All URIs are relative to *http://localhost:4984/*

Method | HTTP request | Description
------------- | ------------- | -------------
[**dbSessionDelete**](SessionApi.md#dbSessionDelete) | **DELETE** /{db}/_session | Delete a user session
[**dbSessionPost**](SessionApi.md#dbSessionPost) | **POST** /{db}/_session | Create a user session


<a name="dbSessionDelete"></a>
# **dbSessionDelete**
> dbSessionDelete(db, opts)

Delete a user session

This request deletes the session that currently authenticates the requests. 

### Example
```javascript
var SyncGateway = require('sync_gateway');
var defaultClient = SyncGateway.ApiClient.default;

// Configure API key authorization: apiKey
var apiKey = defaultClient.authentications['apiKey'];
apiKey.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiKey.apiKeyPrefix = 'Token';

var apiInstance = new SyncGateway.SessionApi();

var db = "db_example"; // String | Database name

var opts = { 
  'cookie': "cookie_example" // String | The cookie of the logged-in session.
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully.');
  }
};
apiInstance.dbSessionDelete(db, opts, callback);
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **db** | **String**| Database name | 
 **cookie** | **String**| The cookie of the logged-in session. | [optional] 

### Return type

null (empty response body)

### Authorization

[apiKey](../README.md#apiKey)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/json

<a name="dbSessionPost"></a>
# **dbSessionPost**
> Session dbSessionPost(db, opts)

Create a user session

If the credentials provided in the request body are valid, the session is created with an idle session timeout of 24 hours. An idle session timeout in the context of Sync Gateway is defined as the following: if 10% or more of the current expiration time has elapsed when a subsequent request with that session id is processed, the session&#39;s expiry time is automatically updated to 24 hours from that time. 

### Example
```javascript
var SyncGateway = require('sync_gateway');
var defaultClient = SyncGateway.ApiClient.default;

// Configure API key authorization: apiKey
var apiKey = defaultClient.authentications['apiKey'];
apiKey.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiKey.apiKeyPrefix = 'Token';

var apiInstance = new SyncGateway.SessionApi();

var db = "db_example"; // String | Database name

var opts = { 
  'sessionBody': new SyncGateway.SessionBody() // SessionBody | The message body is a JSON document that contains the following objects.
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.dbSessionPost(db, opts, callback);
```

### Parameters

Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **db** | **String**| Database name | 
 **sessionBody** | [**SessionBody**](SessionBody.md)| The message body is a JSON document that contains the following objects. | [optional] 

### Return type

[**Session**](Session.md)

### Authorization

[apiKey](../README.md#apiKey)

### HTTP request headers

 - **Content-Type**: Not defined
 - **Accept**: application/json

