login( )


Logs a registered member in with an email and password.

The login() function returns a Promise that resolves to a session token used to log a member in to your site.

The login() function only works with existing members. To register a new member use the register() function.

To complete the login, the returned session token must be applied using the applySessionToken() function (from wix-members-frontend) in page code.

Method Declaration
Copy
function login(email: string, password: string): Promise<string>;
Method Parameters
emailstringRequired

Login email address.


passwordstringRequired

Member password.

Returns
Return Type:Promise<string>
JavaScript
import { Permissions, webMethod } from "wix-web-module"; import { authentication } from "wix-members-backend"; export const myLoginFunction = webMethod( Permissions.Anyone, (email, password) => { return authentication .login(email, password) .then((sessionToken) => { return sessionToken; }) .catch((error) => { console.error(error); }); }, ); /* Promise resolves to a session token: * "JWS.eyJraWQiOiJQSXpvZGJiQiIsImFsZyI6IkhTMjU2In0.eyJkYXRhIjoie1wiaWRcIjpcIjg4MzFlZWQ2LTkyOGUtNGY4NS1iODBhLWUxZTQ4ZmI3YzRmZFwiLFwiY29sbGVjdGlvbklkXCI6XCI5YmVjNThlNi02NDExLTQ5OTEtOGU1ZC0wYWRhOTE4MmI5NWVcIixcIm1ldGFTaXRlSWRcIjpcIjFmZjQ2YTk2LWRlYTYtNDlkYS04M2JhLTUxNjRmYjYyZDgzOVwiLFwib3duZXJcIjpmYWxzZSxcImNyZWF0aW9uVGltZVwiOjE2MjI0MTUxMTMyNjYsXCJleHBpcmVzSW5cIjoxMjA5NjAwMDAwLFwiZXhwaXJhdGlvblRpbWVcIjoxNjIyNDE1MjMzMjY2LFwibGFzdFJlZnJlc2hlZFwiOjAsXCJhZG1pblwiOmZhbHNlfSIsImlhdCI6MTYyMjQxNTExM30.CFJTkyDaF6LypH8UuNm74qgZMxTKFgB1ZnzsemhY_KY" */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?