大网数据广告活动
Web 标准与前端开发

NavigatorLogin: setStatus() method

· 52CE 我爱测

The **`setStatus()`** method of the NavigatorLogin interface sets the login status of a federated identity provider (IdP), when called from the IdP's origin. By this, we mean "whether any users are logged into the IdP on the current browser or not". This should be called by the I

FedCM API

The setStatus() method of the NavigatorLogin interface sets the login status of a federated identity provider (IdP), when called from the IdP's origin. By this, we mean "whether any users are logged into the IdP on the current browser or not". This should be called by the IdP site following a user login or logout.

The browser stores this state for each IdP; the FedCM API then uses it to reduce the number of requests it makes to the IdP (because it does not need to waste time requesting accounts when there are no users logged in to the IdP). It also mitigates potential timing attacks.

See Update login status using the Login Status API for more information about FedCM login status.

Syntax

setStatus(status)

Parameters

  • status
    • : A string representing the login status to set for the IdP. Possible values are:
      • "logged-in": The IdP has at least one user account signed in.
      • "logged-out": All IdP user accounts are currently signed out.

Return value

A Promise that fulfills with undefined.

Exceptions

  • SecurityError DOMException
    • : Thrown if the calling domain is not in a frame where all of the nesting hierarchy is same-origin. Whether called from the main frame, an iframe nested inside the main frame, or another <iframe> nested one or more levels deep inside the first <iframe>, all levels of the nesting hierarchy must be same-origin for the call to be successful.

Examples

/* Set logged-in status */
navigator.login.setStatus("logged-in");

/* Set logged-out status */
navigator.login.setStatus("logged-out");

Specifications

Browser compatibility

See also

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。