> ## Documentation Index
> Fetch the complete documentation index at: https://translations.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Auth0 Dashboard、Management API、Actions を使用して、テナントのセッション有効期間を設定する方法を説明します。

# セッション有効期間を設定する

セッションの有効期間を設定するには、Auth0 [Dashboard](/ja/docs/get-started/auth0-overview/dashboard)、[Management API](https://auth0.com/docs/api/management/v2)、または [Post-Login Action](/ja/docs/customize/actions/explore-triggers/signup-and-login-triggers/login-trigger) を使用できます。

<div id="auth0-dashboard">
  ## Auth0 Dashboard
</div>

Auth0 Dashboard を使用してセッションの有効期間を設定するには、次の手順を実行します。

1. **Dashboard > Tenant Settings** に移動し、**Advanced** ビューを選択します。

2. **Session Expiration** で、次の設定を行います。

| Session Policy                                | Description                              |
| --------------------------------------------- | ---------------------------------------- |
| **Idle Session Lifetime (Persistent)**        | 永続セッションが期限切れになるまでのアイドル状態の最大時間 (分) 。      |
| **Idle Session Lifetime (Non-Persistent)**    | 非永続セッションが期限切れになるまでのアイドル状態の最大時間 (分) 。     |
| **Maximum Session Lifetime (Persistent)**     | ユーザーがアクティブであっても、永続セッションを維持できる最大時間 (分) 。  |
| **Maximum Session Lifetime (Non-Persistent)** | ユーザーがアクティブであっても、非永続セッションを維持できる最大時間 (分) 。 |

<Frame>
  <img src="https://mintcdn.com/translations/xwVvTWJUElMm5YAK/docs/images/cdy7uua7fh8z/session-lifetime/Dashboard-Tenant-Settings-Advanced-Session-expiration.png?fit=max&auto=format&n=xwVvTWJUElMm5YAK&q=85&s=872d4e8001eac21c3257cf1ab2f45dd5" alt="Dashboard > Tenant > Settings > Advanced > Session Expiration" data-og-width="1404" width="1404" data-og-height="995" height="995" data-path="docs/images/cdy7uua7fh8z/session-lifetime/Dashboard-Tenant-Settings-Advanced-Session-expiration.png" data-optimize="true" data-opv="3" srcset="https://mintcdn.com/translations/xwVvTWJUElMm5YAK/docs/images/cdy7uua7fh8z/session-lifetime/Dashboard-Tenant-Settings-Advanced-Session-expiration.png?w=280&fit=max&auto=format&n=xwVvTWJUElMm5YAK&q=85&s=3391c1ca5e91525ecb7558edd3151fda 280w, https://mintcdn.com/translations/xwVvTWJUElMm5YAK/docs/images/cdy7uua7fh8z/session-lifetime/Dashboard-Tenant-Settings-Advanced-Session-expiration.png?w=560&fit=max&auto=format&n=xwVvTWJUElMm5YAK&q=85&s=99f16e23b82b6bb3f11b3f7974881bc8 560w, https://mintcdn.com/translations/xwVvTWJUElMm5YAK/docs/images/cdy7uua7fh8z/session-lifetime/Dashboard-Tenant-Settings-Advanced-Session-expiration.png?w=840&fit=max&auto=format&n=xwVvTWJUElMm5YAK&q=85&s=8bbc870a9d6268df888c4ec2ecf26b3f 840w, https://mintcdn.com/translations/xwVvTWJUElMm5YAK/docs/images/cdy7uua7fh8z/session-lifetime/Dashboard-Tenant-Settings-Advanced-Session-expiration.png?w=1100&fit=max&auto=format&n=xwVvTWJUElMm5YAK&q=85&s=611796cf24580991e42d972a75ba92a7 1100w, https://mintcdn.com/translations/xwVvTWJUElMm5YAK/docs/images/cdy7uua7fh8z/session-lifetime/Dashboard-Tenant-Settings-Advanced-Session-expiration.png?w=1650&fit=max&auto=format&n=xwVvTWJUElMm5YAK&q=85&s=e8a5a7d4bdeac1d1c8f48e4d94c12369 1650w, https://mintcdn.com/translations/xwVvTWJUElMm5YAK/docs/images/cdy7uua7fh8z/session-lifetime/Dashboard-Tenant-Settings-Advanced-Session-expiration.png?w=2500&fit=max&auto=format&n=xwVvTWJUElMm5YAK&q=85&s=ded65ea79a841a19d814c5433bbc40b5 2500w" />
</Frame>

<div id="auth0-management-api">
  ## Auth0 Management API
</div>

Auth0 Management API を使用してセッションの有効期間を設定するには、次のようにします。

<Callout icon="file-lines" color="#0EA5E9" iconType="regular">
  `/api/v2/tenants/settings` エンドポイントを呼び出すには、`update:tenant_settings` スコープを持つ [Management API アクセストークン](/ja/docs/secure/tokens/access-tokens) が必要です。
</Callout>

[/api/v2/tenants/settings](/ja/docs/api/management/v2/tenants/patch-settings) エンドポイントに `PATCH` リクエストを送信します。

```bash cURL theme={null}
curl --request PATCH \
  --url 'https://<your-domain>/api/v2/tenants/settings' \
  --header 'Authorization: Bearer MGMT_API_ACCESS_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{\
    "session_lifetime": SESSION_LIFETIME_VALUE,\
    "idle_session_lifetime": IDLE_SESSION_LIFETIME_VALUE,\
    "ephemeral_session_lifetime": EPHEMERAL_SESSION_LIFETIME_VALUE,\
    "idle_ephemeral_session_lifetime": EPHEMERAL_IDLE_SESSION_LIFETIME_VALUE\
  }'
```

| パラメーター                            | 説明                                           |
| --------------------------------- | -------------------------------------------- |
| `session_lifetime`                | 絶対タイムアウトまでの最大時間 (時間単位) 。                     |
| `idle_session_lifetime`           | 非アクティブ状態が続いた場合にセッションが期限切れになるまでの最大時間 (時間単位) 。 |
| `ephemeral_session_lifetime`      | 絶対タイムアウトまでの最大時間 (時間単位) 。                     |
| `idle_ephemeral_session_lifetime` | 非アクティブ状態が続いた場合にセッションが期限切れになるまでの最大時間 (時間単位) 。 |

<div id="auth0-post-login-actions">
  ## Auth0 Post-Login Actions
</div>

[post-login Action](/ja/docs/customize/actions/explore-triggers/signup-and-login-triggers/login-trigger) で `api.session` メソッドを使用すると、セッションの動作を動的に設定できます。これにより、ユーザーまたはコンテキスト固有のロジックに基づいて、ログインごとにテナントのデフォルトのセッション設定を上書きできます。

ユースケースには次のようなものがあります。

* リスクの高いログインのタイムアウトを短縮する

* 信頼できるユーザーまたは組織のタイムアウトを延長する

* アプリケーションの種類に応じてクッキーの永続性を調整する

セッションの有効期間を設定するために使用できる `api.session` メソッドは、次のとおりです。

* `api.session.setExpiresAt`

* `api.session.setIdleExpiresAt`

* `api.session.setCookieMode`

<Callout icon="file-lines" color="#0EA5E9" iconType="regular">
  `api.session` メソッドは現在のセッションにのみ適用され、ログイン トランザクション中に呼び出す必要があります。これらのメソッドを使用するには、イベント プロパティ `event.session.id` が利用可能である必要があります。
</Callout>

詳細については、[Sessions with Actions](/ja/docs/manage-users/sessions/manage-sessions-actions) を参照してください。
