Hi. I’m trying to make a website where people have to login to be able to see some contents. But I kind of got stuck. I’m trying to use cookies, but I can’t get them to work. (The following code is to test if the cookies/site work)
Login page:
<html>
<head>
<script language="javascript">
<!--
function setcookie(){
document.cookie = "logged="+escape("Dom Director")
window.location = "/site.html"}
</script>
</head>
<body onload="setcookie()"></body>
</html>
Site Page:
<html>
<head><title>TITLU</title>
</script>
<script language="javascript">
<!--
function getCookie(cookies){
var results = document.cookie.match ( '(^|;) ?' + cookies + '=([^;]*)(;|$)' );
if ( results )
return ( unescape ( results[2] ) );
else
return null;}
</script>
</head>
<body>
<table width="100%">
<tr height="150"></tr>
<tr><td width="150">bara navigatie</td>
<td width="0*"><img src="400p.png">
<script>if (!getCookie('logged'))
document.write('You're not logged in.')
else
document.write('Hello , '+getCookie("logged"))</script>
The problem is that it doesn’t matter if I load the site page or the login page, I only get “you’re not logged in”, so either the cookie isn’t being set, or the search doesn’t find the cookie.
Any help will be very much appreciated. Bye.