I'm running into an issue getting a cookie to store. The code below works for it's intended purpose. Which is to save just the first.last name put in, user has to put joe.smith not joe then smith. The cookie saves which is good, but after the browser is closed it removes the cookie. I know somehow i have to give an expiration date to it, but I can't seem to figure it out. What would be straightforward way of adding the expiration date to be permanent?
<!DOCTYPE html>
<html>
<script>
function writeCookie(){
if(document.cookie === "")
{
document.cookie = prompt("Enter first.last name: ");
}
}
writeCookie();
var name = document.cookie;
document.write("Your name is: ");
document.write(name);
</script>
</body>
</html>