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
Session and cookies problem.
Moderator: General Moderators
Re: Session and cookies problem.
No, but you may have set the cookies to only affect a certain directory. Make sure the 4th parameter is set to '/'.
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Session and cookies problem.
Can you paste the code used to set the cookie
“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
Re: Session and cookies problem.
Hello,
This is the same code work for another project but not working for my current project.
Here is my code.
Thanks in advance,
thenndral
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;
thenndral
Re: Session and cookies problem.
Hello,
No replies. Give some idea. It's Urgent.
thanks,
thenndral
No replies. Give some idea. It's Urgent.
thanks,
thenndral