Page 1 of 1
Session and cookies problem.
Posted: Tue May 03, 2011 3:03 am
by thenndral
Hello,
I have a problem in cookies setting.
let me explain my problem.
I want to store my login details in cookies.
I have a source for login page. this source from our another project source. I copied the same source and paste it on my current project. but my login page not set cookies, it return empty.
source same as previous project and login table also same.
difference is project name and DB name.
my question is, for my new project any setting have to do for cookies and sessions.
Any ideas or code help?
Thanks in advance,
thenndral
Re: Session and cookies problem.
Posted: Tue May 03, 2011 8:40 am
by oscardog
No, but you may have set the cookies to only affect a certain directory. Make sure the 4th parameter is set to '/'.
Re: Session and cookies problem.
Posted: Tue May 03, 2011 11:28 am
by social_experiment
Can you paste the code used to set the cookie
Re: Session and cookies problem.
Posted: Tue May 03, 2011 10:33 pm
by thenndral
Hello,
This is the same code work for another project but not working for my current project.
Here is my code.
Code: Select all
setrawcookie("id_Cookie", $req_Userid, 0, "/"); //set cookie with userid.
setrawcookie("Cookie_UName", $arr_userinfo['name'], 0, "/"); //set cookie with user name
include_once("../include/common_class.php");
include_once("../include/db_class_mysqli.php");
$req_Userid = $_POST["loginUserId"];
$req_Userpwd= $_POST["loginUserPwd"];
if ( $req_Userid && $req_Userpwd )
{
$db = new DB_MYSQL();
$returnValue = $db->isExistUserInfo($req_Userid,$req_Userpwd);
if ( $returnValue )
{
$db = new DB_MYSQL();
$arr_userinfo = $db->getSecurityLevel_DB($req_Userid);
if ( $db->getCount() < 1 ) {
echo <<<__HTML__
<script lang='javascript'>
alert('Incorrect Login id!');
history.go(-1);
</script>
__HTML__;
}
$userUid = ($arr_userinfo['uid']);
$userName = ($arr_userinfo['name']);
setcookie("id_Cookie", $req_Userid, 0, "/", $_SERVER['HTTP_HOST'], 0); //set cookie with userid.
setcookie("Cookie_UName", $userName, 0, "/", $_SERVER['HTTP_HOST'], 0); //set cookie with user name
echo <<<__HTML__
<script language='javascript'>
location.href = "/main.php";
</script>
__HTML__;
} else {
echo <<<__HTML__
<script language='javascript'>
alert('Login Failed!');
location.href = "index.html";
</script>
__HTML__;
}
}
$db = null;
Thanks in advance,
thenndral
Re: Session and cookies problem.
Posted: Tue May 10, 2011 8:21 pm
by thenndral
Hello,
No replies. Give some idea. It's Urgent.
thanks,
thenndral