Last active
March 26, 2022 01:22
-
-
Save onedebos/93ef2818c4028c315daf74d0f20655f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pages/login.js | |
import { useCookies } from "react-cookie" | |
const Login = () => { | |
const [cookie, setCookie] = useCookies(["user"]) | |
const handleSignIn = async () => { | |
try { | |
const response = await yourLoginFunction(username) //handle API call to sign in here. | |
const data = response.data | |
setCookie("user", JSON.stringify(data), { | |
path: "/", | |
maxAge: 3600, // Expires after 1hr | |
sameSite: true, | |
}) | |
} catch (err) { | |
console.log(err) | |
} | |
} | |
return ( | |
<> | |
<label htmlFor="username"> | |
<input type="text" placeholder="enter username" /> | |
</label> | |
</> | |
) | |
} | |
export default Login |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment