You could end up with 2 cookies if your session uses cookies to keep track of sessions.1skazi wrote:If i use session and cookie in the same script then which will be placed at first ?
Which will be placed at first in a script session or cookie?
Moderator: General Moderators
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Which will be placed at first in a script session or coo
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
- flying_circus
- Forum Regular
- Posts: 732
- Joined: Wed Mar 05, 2008 10:23 pm
- Location: Sunriver, OR
Re: Which will be placed at first in a script session or coo
My money is on $_SESSION, because $_COOKIE won't be able available until the next page request.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>