I Can’t Make A Cookie In An Html File…
document.cookie = "Lang:Ar";
When It’s Time To Preview:
In Inspect Section > Console :
document.cookie
''
So I Tried To Turn The Cookie Into A Function :
function SetCookie(Key,Val) {
document.cookie = Key + "=" + Val;
}
But It Didn’t Success…
1.Creating The Cookie :
SetCookie("Lang","Ar");
"Lang", "Ar"
2.Previewing It :
document.cookie
''
The Same Thing ðŸ˜
But It Worked Only On LiveServer In VScode.
2
Answers
Personnally I’m using this:
(It only works if you access the document in HTTP or HTTPS)
You should look at Mamp or Xamp for learning a bit about serving your code locally
Here is a step by step guide on how to install XAMPP:
https://www.youtube.com/watch?v=VCHXCusltqI
If you are working entirely on the front-end, you can use WebStorage.
With WebStorage, you have two options:
Example:
You can use
localStorage
as follows: