Jump to content

[SOLVED] problem with cookies !!


yami007

Recommended Posts

well here's what i want to do

set the cookie on a directory, and call it back from other directory

ex : set on install/install.php and call it back on admin/profile.php

thought it would work without problems

dont know what i did wrong anyway

 

my code for install.php:

<?php
$_SESSION['pseudo'] = $pseudo;
$_SESSION['password'] = $password;

$time_expire = time() + 365*24*3600;
setcookie('pseudo', $pseudo, $time_expire);
setcookie('password', $password, $time_expire);
?>

 

here is the 2nd code for profile.php :

<?php
if(($_COOKIE['pseudo']) AND ($_COOKIE['password'])) {

	$pseudo = $_COOKIE['pseudo'];
	$password = $_COOKIE['password'];

	// try to find a user who looks like the cookies
	$query = "SELECT admin_email,admin_password FROM admin_cp 
		WHERE admin_email='{$pseudo}' 
		AND admin_password='{$password}' 
		LIMIT 1
		";

	$result = mysql_query($query) or die(mysql_error());
	$found_one = mysql_num_rows($result);
	if ($found_one > 0) {
		$_SESSION['pseudo'] = $pseudo;
	}
}
?>

 

for the same directory it works fine :

code for admin/login.php

 

<?php 
$_SESSION['pseudo'] = $pseudo;
$_SESSION['password'] = $password;

if ( $autologin == 1 ) {
$time_expire = time() + 365*24*3600;
setcookie('pseudo', $pseudo, $time_expire);
setcookie('password', $password, $time_expire);
}
?>

so what's the problem??  >:(

Link to comment
https://forums.phpfreaks.com/topic/175796-solved-problem-with-cookies/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.