{"id":29150154,"url":"https://github.com/humanmade/rest-sessions","last_synced_at":"2025-07-22T02:33:37.422Z","repository":{"id":29187330,"uuid":"120420572","full_name":"humanmade/rest-sessions","owner":"humanmade","description":"Log in and out of WordPress using the REST API.","archived":false,"fork":false,"pushed_at":"2025-02-20T16:41:58.000Z","size":14,"stargazers_count":18,"open_issues_count":0,"forks_count":2,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-06-30T16:14:53.884Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/humanmade.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-06T07:54:32.000Z","updated_at":"2025-02-20T17:47:05.000Z","dependencies_parsed_at":"2022-09-01T22:50:45.090Z","dependency_job_id":null,"html_url":"https://github.com/humanmade/rest-sessions","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/humanmade/rest-sessions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humanmade%2Frest-sessions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humanmade%2Frest-sessions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humanmade%2Frest-sessions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humanmade%2Frest-sessions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/humanmade","download_url":"https://codeload.github.com/humanmade/rest-sessions/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humanmade%2Frest-sessions/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262864258,"owners_count":23376461,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-30T23:09:43.886Z","updated_at":"2025-06-30T23:09:44.696Z","avatar_url":"https://github.com/humanmade.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ctable width=\"100%\"\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd align=\"left\" width=\"70%\"\u003e\n\t\t\t\u003cstrong\u003eREST Sessions\u003c/strong\u003e\u003cbr /\u003e\n\t\t\tLog in and out with cookie authentication.\n\t\t\u003c/td\u003e\n\t\t\u003ctd align=\"right\" width=\"20%\"\u003e\n\t\t\t\u003cbr /\u003e\n\t\t\u003c/td\u003e\n\t\u003c/tr\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd\u003e\n\t\t\tA \u003cstrong\u003e\u003ca href=\"https://hmn.md/\"\u003eHuman Made\u003c/a\u003e\u003c/strong\u003e project. Maintained by @rmccue.\n\t\t\u003c/td\u003e\n\t\t\u003ctd align=\"center\"\u003e\n\t\t\t\u003cimg src=\"https://hmn.md/content/themes/hmnmd/assets/images/hm-logo.svg\" width=\"100\" /\u003e\n\t\t\u003c/td\u003e\n\t\u003c/tr\u003e\n\u003c/table\u003e\n\nWorking on a REST API-powered theme, and want to include a login form? You need REST Sessions.\n\n\n## Installation\n\nActivate this plugin.\n\nIn order to use the API endpoints, you need to pass a login nonce to the API endpoints. You can get this nonce easily in PHP by calling `REST_Sessions\\Session_Controller::get_nonce()`.\n\n\n## Usage\n\nRather than explicitly logging in or out, the endpoints used by this plugin create or destroy sessions. These are the real session objects used under the hood by WordPress, and this fits better with the resource-based paradigm used by REST.\n\n\n### Create a Session (Log In)\n\nTo log in, you create a session. To create a session, send a `POST` request to `/sessions/v0/sessions`. You need to include the following parameters (preferably in a JSON body):\n\n* `username` (string): User-supplied username.\n* `password` (string): User-supplied password.\n* `auth_nonce` (string): Nonce generated by the backend.\n* `remember` (boolean): True to persist cookies, false to use short-lived ones. Default is `false`.\n\nOn success, this will return a 201 Created status code with a Session resource in the body. Additionally, it will set the authentication cookies for the site.\n\n\n### Destroy the Current Session (Log Out)\n\nTo log out, you destroy the current session. To destroy the session, send a `DELETE` request to `/sessions/v0/sessions/current`. You need to include the REST API nonce for the current user as the `_wpnonce` parameter, just like any other authenticated endpoint.\n\nOn success, this will return a 200 OK status code with a JSON object containing the following properties in the body:\n\n* `deleted` (boolean): True on success.\n* `previous` (object): The Session resource that has just been destroyed.\n\n\n### Session Resource\n\nThe Session resource returned from these endpoints is a JSON object containing the following properties:\n\n* `id` (string): Session ID.\n* `created` (string): ISO8601 datetime representing the creation time of the session.\n* `expiration` (string): ISO8601 datetime representing the expiration time of the session.\n* `ip` (string): IP address registered for the session.\n* `user_agent` (string): User agent registered for the session.\n* `nonce` (string): Nonce for use with authenticated REST API endpoints.\n\nAdditionally, an `author` link is added pointing to the current user. This link is embeddable.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhumanmade%2Frest-sessions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhumanmade%2Frest-sessions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhumanmade%2Frest-sessions/lists"}