Re: sessions and first time load
| From: | Julio Nobrega Trabalhando | Date: | Wed, 07 Nov 2001 17:09:56 +0000 |
| Subject: | Re: sessions and first time load | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-73758@lists.php.net to get a copy of this message | ||
Because cookies are set but cannot be read on the same document... You
would need to reload or load another document to be able to 'read' the
cookie...
--
Julio Nobrega
A hora está chegando:
http://toca.sourceforge.net
"Bas Jobsen" <bas@startpunt.cc> wrote in message
news:032901c167ab$ceea1380$9600000a@lan...
> 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
>