Page 1 of 1

Re: Which will be placed at first in a script session or coo

Posted: Fri Aug 19, 2011 10:28 am
by social_experiment
1skazi wrote:If i use session and cookie in the same script then which will be placed at first ?
You could end up with 2 cookies if your session uses cookies to keep track of sessions.

Re: Which will be placed at first in a script session or coo

Posted: Fri Aug 19, 2011 10:54 am
by flying_circus
1skazi wrote:If i use session and cookie in the same script then which will be placed at first ?
Is it a valid code:

<?php session_start(); setcookie("user", "Roger", time()+3600); ?>
<html><body>
<?php
$_SESSION["name"]="Jone";
echo $_SESSION["name"]."<br/>";
echo $_COOKIE["user"];
?>
</body></html>
My money is on $_SESSION, because $_COOKIE won't be able available until the next page request.