sessions and first time load
| From: | Bas Jobsen | Date: | Wed, 07 Nov 2001 16:46:49 +0000 |
| Subject: | sessions and first time load | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-73752@lists.php.net to get a copy of this message | ||
Hello,
I'm using the code showed below:
<?php
setcookie("aname", "somedata");
if(!empty($HTTP_COOKIE_VARS["aname"]))$cookie=true;
else $cookie=false;
session_register ("bas");
?>
<a href="test.php3">test</a>
<script type="text/javascript" language="JavaScript">
<!--
d=document;
d.write("<a href=\"http://www.linkotheek.nl/\"
target=\"_top\">");
file://-->
</script>
<?
if ($cookie) echo "Yeah, cookies!";
else echo "No cookies :(";
?>
When I load the page for the first time, the result is: "No cookies :("
Why is that?
Also gives this a problem, cause by using sessions, php puts ?PHPSESSID=....
behinds the URLs. This goes wrong with the javascript (error).
From the html-source code:
d.write("<a
href="\?PHPSESSID=89b65598b4579214ea935d825f51ea91""http://www.linkotheek.nl
/\" target=\"_top\">");
Tnx,
Bas