Anyone facing an issue "needs to refresh to show the Logout button in the navbar after login" add setToken(servertoken); a line in stroteTokenInLS function
sir error plez help - mera login kare ke navbar par logout dikhta hey, lekin jaise logout click karta hu to logout hota hey , or login page par redirect kara ta hey , lekin navbar se logout nahi jata - help
Hey man The token will be in local storage even though the token is expired u are not explained it.I came to this video for that doubt but i cant get it...
Yo Series malai sabse hard chai JWT, Log out functionality lago. Quki main react ki badle nextjs use karahahu frontend. Thori idar udar chatgpt use karke aur aapke code k sath khelte huye solve vi horaha hain. Lekin Login karte samme harek time refresh karna parra ha hain. Yo kya karke hataye ye samaj me nai aaya
hey there? 1-) In auth.js: //add the settoken state funct in value prop return //added settoken here {children};
2-)In Login.jsx: //construct these value from useAuthhook const {storeTokenInLS, settoken}=useAuth(); handlelogin=()=>{ //remaining logic same rahey gi settoken(response.data.token) //add this here storeTokenInLS(response.data.token) } 3-) Navbar logic: const {isLoggesin }= useAuth();
Thapa bhaiya, mai jb login kr rha hu to suddenly logout button show nhi kr rha h, page refresh krne k baad logout button show ho rha h, isko kaise thik kru😢 Baaki everything is okayy
! is 'not' and works as negation, but !! is double 'not' and make 'isLoggedIn' a boolean without actually making it. If we directly write: const isLoggedIn = token; it will simply asign the token to isLoggedIn variable
Sir,You did not handled Login and logout in Navbar,After login, Logout does not come in Navbar, Sirf Login aur Register hi rahta hai navbar me Login karne k baad v. plz Help. @ThapaTechnical
Sir, Never stop teaching.. you are the best 😊
Thank you, I will
Nice video but please explain why we need to refresh to show Logout button in navbar after login
bro search on chat gpt what is refresh and acces token else you can also search on
youtube
thats a real problem... have you feagured it out brother ??
best mern series
Best boss, What an amazing tutorial, right on time...I just needed it and you upload...lots of love!!!
This topic is nicely taught. Thanks a lot sir
learned alot from your videos ...thank you so much sir
Anyone facing an issue "needs to refresh to show the Logout button in the navbar after login" add setToken(servertoken); a line in stroteTokenInLS function
import { createContext, useContext, useState } from "react";
export const AuthContext =createContext();
export const AuthProvider=({children})=>{
const [token,setToken]=useState(localStorage.getItem("token"))
let isLoggedIn=!!token
const stroteTokenInLS=(servertoken)=>
{
localStorage.setItem("token",servertoken)
setToken(servertoken);
}
const LogoutUser=()=>{
localStorage.removeItem("token")
setToken("");
}
return({children});
}
export const useAuth=()=>{
return useContext(AuthContext)
}
a complete new line or instead of setItem ?
Thanks man☺. Its works.....
Please explain why we need to refresh the page to show Logout button? why isn't it coming automatically? I done the same and facing the same issue
same question....
sir error plez help - mera login kare ke navbar par logout dikhta hey, lekin jaise logout click karta hu to logout hota hey , or login page par redirect kara ta hey , lekin navbar se logout nahi jata - help
@ThapaTechnical
same roblem
I am facing same issue, kaise resolve kiya?
same problem? any solution
@@yogeshpatidar8195 i give you my code, you check i make this already
osm sir osm really great teach you are a lot of respect
please upload at least two videos per day
Thapa bhai sachi bataun to aap great ho bhai 🥰🥰🥰🥰
playlist ka link kyu nai dalte ho
thanku thapa bhai
Hey man
The token will be in local storage even though the token is expired u are not explained it.I came to this video for that doubt but i cant get it...
Completed 19/12/2024 - 23:10
why are we using different route for logout
Yo Series malai sabse hard chai JWT, Log out functionality lago. Quki main react ki badle nextjs use karahahu frontend. Thori idar udar chatgpt use karke aur aapke code k sath khelte huye solve vi horaha hain. Lekin Login karte samme harek time refresh karna parra ha hain. Yo kya karke hataye ye samaj me nai aaya
hey there?
1-)
In auth.js:
//add the settoken state funct in value prop
return //added settoken here
{children};
2-)In Login.jsx:
//construct these value from useAuthhook
const {storeTokenInLS, settoken}=useAuth();
handlelogin=()=>{
//remaining logic same rahey gi
settoken(response.data.token) //add this here
storeTokenInLS(response.data.token)
}
3-)
Navbar logic: const {isLoggesin }= useAuth();
{isLoggedIn ? (
Logout
Profile
) : (
Register
Login
)}
Home
kamal❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤
Thapa bhaiya, mai jb login kr rha hu to suddenly logout button show nhi kr rha h, page refresh krne k baad logout button show ho rha h, isko kaise thik kru😢
Baaki everything is okayy
same mere sath ho ra hai agr solution mile to btaye bhai jrur
@@DivansuPandat bhai maine solve krr liye, jb login kroge usi time instant token store krrna Localstorage se get krrke, fix ho jayega
bhai login krne pr to token localstorage me store hora hai but logout ni suddenly ara refresh krne ke bad ata hai logout@@farhanakhtar971
kaise krna hai bro@@farhanakhtar971
help
@@farhanakhtar971
Sir, Login Hone Ke Bad Refresh Krte hai to LogOut option hat jata h per hmko button click pe hi hatana tha
yarr mera login hone ke bad lgout option ata ni but refresh krta hu tb a jata hai
Bhai solution mila iska
@@factsshortshindi Haaa Bhai Mil gya tha
@@gamingarizonaofficial iska solution kya the bhai?
@@factsshortshindiBro Iska solution ChatGpt😂
import analysis ka error aa rha hai wo kse solve kre?
sir can we do authentication using cookies in this series...
Yes why not
Make one video on otp verification on email registration
Sir truly batu to sayad apko bura lage aur mere baat faltu lage but , your video thodi complex hai manta hu ki for a begineer ,
what does '!!' mean? I learned '!"
! is 'not' and works as negation, but !! is double 'not' and make 'isLoggedIn' a boolean without actually making it. If we directly write: const isLoggedIn = token; it will simply asign the token to isLoggedIn variable
as in - - = + as we did in math
Sir Navbar Responsive nhi kiya aapne
Ha bhai har chiz tuze bani banayi chahiye
Utna to tu kr sakta he na
Sure karnegey karengey
@@ThapaTechnical I was points to that person not you ❤️
Sorry if you think this one was for you🙏
thnk u sir@@ThapaTechnical
mere me login krne pe data ja raha hai lekin tokan store nahi ho raha
Localstorage me save kr rhe ho ya nhi
@@farhanakhtar971 ha
🙏🙏❤❤
👍🙏
Sir,You did not handled Login and logout in Navbar,After login, Logout does not come in Navbar, Sirf Login aur Register hi rahta hai navbar me Login karne k baad v. plz Help. @ThapaTechnical
same question
@@prachideokate6309 reload the page