سلام.
من خیلی وقته که با ست کردن کوکی با لوکال هاست xampp مشکل دارم. کدم رو هم هرجایی میذارم میگن درسته.
چند وقته که کوکی ها ست میشن، ولی نمیدونم چرا تستشون نیمه اشتباه در میاد! این کد ست کوکی:
setcookie("userlog", $username, $time + 250, '/', '.localhost', 0);
setcookie("pwUser", $password, $time + 250, '/', '.localhost', 0);
این هم کد تست کوکی ها:
<?php
//cookies and sessions checker!
session_start();
include 'dtbscnnect.php';
mysql_select_db('test');
if (isset($_COOKIE['userlog']) && isset($_COOKIE['pwUser'])) {
$userexists_query = mysql_query("SELECT username, vPass FROM users WHERE username = '$_COOKIE[userlog]' and vPass = '$_COOKIE[pwUser]'");
if (mysql_num_rows($userexists_query) != 0) {
$userexists = $_COOKIE['userlog'];
$passexists = $_COOKIE['pwUser'];
if (isset($_SESSION['admin']) && isset($_SESSION['pwAdmin'])) {
$adminexists_query = mysql_query("SELECT username, vPass, admin FROM users WHERE username = '$_SESSION[admin]' and vPass = '$_SESSION[pwAdmin]' and admin = 'True'");
if (mysql_num_rows($adminexists_query) != 0) {
$adminexists = $_SESSION['admin'];
$adminPWexists = $_SESSION['pwAdmin'];
} else {
$adminexists = 0;
$adminPWexists = 0;
}
} else {
$adminexists = 0;
$adminPWexists = 0;
}
} else {
$userexists = 0;
$passexists = 0;
$adminPWexists = 0;
$adminexists = 0;
}
} else {
$userexists = 0;
$passexists = 0;
$adminexists = 0;
$adminPWexists = 0;
}
mysql_close();
?>