session won´t use cookies
| From: | Tobias Talltorp | Date: | Fri, 02 Mar 2001 18:19:08 +0000 |
| Subject: | session won´t use cookies | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-42375@lists.php.net to get a copy of this message | ||
I have a problem with the session not using cookies.
The code below doesn´t seem to set a cookie even though my php.ini has it
set.
If I use the header after initializing the session, nothing appears in
getsess.php.
If I click the link on the other hand, the PHPSESSID-variable is added to
the URL.
What do I do to enable the cookies?
(I know how ordinary cookies work and how to set and delete them=
<?
// -- default.php -->
if ($submit) {
$pref_username = "tobias";
$pref_password = "password";
if ($pref_username == $username && $pref_password == $password) {
session_start();
session_register("SESSION");
$SESSION["username"] = $username;
$SESSION["password"] = $password;
// header("Location: getsess.php");
// echo "<a href=getsess.php>go</a>";
} else {
header("Location: $PHP_SELF?username=$username");
}
}
?>
<form method="post" action="<? echo $PHP_SELF; ?>">
Username: <input type="text" name="username" value="<? echo
$username; ?>">
<br>
Password: <input type="text" name="password">
<br>
<input type="submit" name="submit">
</form>
// -- getsess.php -->
<?
session_start();
echo $SESSION["username"];
echo $SESSION["password"];
?>
What am I missing?
Thanks
// Tobias