Cookie not set in my application
Moderator: General Moderators
-
salehalatif
- Forum Newbie
- Posts: 9
- Joined: Wed Jan 28, 2009 12:03 am
Cookie not set in my application
Hello every1!
plz tell me why the cookie in my application is not set.
********LoginAction.php Code:********
ini_set("session.cookie_domain", ".myapp.com");
$EncUID = md5($ffUID);
if ($User[Type] == "CUST") {
setcookie("vplc", $EncUID, time()+3600, '/', '.myapp.com');
$RedirectTo = "http://www.myapp.com/Home.php?aaaa=$EncUID";
}
*********************************
plz tell me why the cookie in my application is not set.
********LoginAction.php Code:********
ini_set("session.cookie_domain", ".myapp.com");
$EncUID = md5($ffUID);
if ($User[Type] == "CUST") {
setcookie("vplc", $EncUID, time()+3600, '/', '.myapp.com');
$RedirectTo = "http://www.myapp.com/Home.php?aaaa=$EncUID";
}
*********************************
-
jothirajan
- Forum Commoner
- Posts: 69
- Joined: Tue Jan 27, 2009 12:06 am
Re: Cookie not set in my application
Just try this
if ($User[Type] == "CUST")
{
session_register("CUST");
$_SESSION['CUST']=$User[Type] ;
header("location:index.php") //// or something you want to have .......
}
Next go to that redirected page index.php
and print the $_session print_r($_session) ...there you can find the session.
Thanks
JOE....get me..if you want more to share
if ($User[Type] == "CUST")
{
session_register("CUST");
$_SESSION['CUST']=$User[Type] ;
header("location:index.php") //// or something you want to have .......
}
Next go to that redirected page index.php
and print the $_session print_r($_session) ...there you can find the session.
Thanks
JOE....get me..if you want more to share
-
salehalatif
- Forum Newbie
- Posts: 9
- Joined: Wed Jan 28, 2009 12:03 am
Re: Cookie not set in my application
jothirajan thank you for you help
but its still the same error.
i have security.inc.php file, which when adding your code i disabled
**********security.inc.php**********
<?php
ob_start();
// include files
ini_set("session.cookie_domain", ".myapp.net");
// intances of include files
$qryUID = $_REQUEST['aa'];
if($qryUID == '' && isset($_COOKIE['vplc']))
$qryUID = $_COOKIE["vplc"];
else
setcookie('vplc', $qryUID,time()+3600 );
$UID = $myUser->getUIDByEncUID($qryUID) ; // GET USER UID LIKE '20022'
$UserInfo = $myUser->getUserInfo($UID); // GET USER UID LIKE '20022'
$OID = $UserInfo[UID];
if ($UserInfo[UID] =="")
{
echo "Session expire";
}
?>
but its still the same error.
i have security.inc.php file, which when adding your code i disabled
**********security.inc.php**********
<?php
ob_start();
// include files
ini_set("session.cookie_domain", ".myapp.net");
// intances of include files
$qryUID = $_REQUEST['aa'];
if($qryUID == '' && isset($_COOKIE['vplc']))
$qryUID = $_COOKIE["vplc"];
else
setcookie('vplc', $qryUID,time()+3600 );
$UID = $myUser->getUIDByEncUID($qryUID) ; // GET USER UID LIKE '20022'
$UserInfo = $myUser->getUserInfo($UID); // GET USER UID LIKE '20022'
$OID = $UserInfo[UID];
if ($UserInfo[UID] =="")
{
echo "Session expire";
}
?>
Last edited by salehalatif on Tue Feb 17, 2009 11:24 pm, edited 1 time in total.
-
jothirajan
- Forum Commoner
- Posts: 69
- Joined: Tue Jan 27, 2009 12:06 am
Re: Cookie not set in my application
can you give me your php file and the page you want to redirect?...
I will review and sort the issues...here in this content i cant clearly get you...
Thanks
JOE
I will review and sort the issues...here in this content i cant clearly get you...
Thanks
JOE
-
salehalatif
- Forum Newbie
- Posts: 9
- Joined: Wed Jan 28, 2009 12:03 am
Re: Cookie not set in my application
which file you want?
i want to redirect it to Home.php
i want to redirect it to Home.php
-
jothirajan
- Forum Commoner
- Posts: 69
- Joined: Tue Jan 27, 2009 12:06 am
Re: Cookie not set in my application
follow this
>>> just leave the php file you have
1) set the session name
2) if (condition=="ok")
{
set session;
and redirect;
}
3) go to the redirected page
print the session >> to check whether the session appears or not
>>> just leave the php file you have
1) set the session name
2) if (condition=="ok")
{
set session;
and redirect;
}
3) go to the redirected page
print the session >> to check whether the session appears or not
-
salehalatif
- Forum Newbie
- Posts: 9
- Joined: Wed Jan 28, 2009 12:03 am
Re: Cookie not set in my application
i put this code in a file cookie.php & excute it. Result: No Cookie Created!
This code is correct ??
<?php
// set the cookies
setcookie("cookie[three]", "cookiethree");
setcookie("cookie[two]", "cookietwo");
setcookie("cookie[one]", "cookieone");
// after the page reloads, print them out
if (isset($_COOKIE['cookie'])) {
foreach ($_COOKIE['cookie'] as $name => $value) {
echo "$name : $value <br />\n";
}
}
else
{
echo "No Cookie Created!";
}
?>
This code is correct ??
<?php
// set the cookies
setcookie("cookie[three]", "cookiethree");
setcookie("cookie[two]", "cookietwo");
setcookie("cookie[one]", "cookieone");
// after the page reloads, print them out
if (isset($_COOKIE['cookie'])) {
foreach ($_COOKIE['cookie'] as $name => $value) {
echo "$name : $value <br />\n";
}
}
else
{
echo "No Cookie Created!";
}
?>
Re: Cookie not set in my application
Try session_start() in the beginning of your document.
-
salehalatif
- Forum Newbie
- Posts: 9
- Joined: Wed Jan 28, 2009 12:03 am
Re: Cookie not set in my application
for Session:
********session.php*******
<?php
session_start();
$_SESSION['views'] = 1; // store session data
echo "Pageviews = ". $_SESSION['views']; //retrieve data
?>
Result:
PageViews= 1
means session is created.
********session.php*******
<?php
session_start();
$_SESSION['views'] = 1; // store session data
echo "Pageviews = ". $_SESSION['views']; //retrieve data
?>
Result:
PageViews= 1
means session is created.
-
jothirajan
- Forum Commoner
- Posts: 69
- Joined: Tue Jan 27, 2009 12:06 am
Re: Cookie not set in my application
Yes this is correct.
So you can set the session
<?php
session_start();
$_SESSION['views'] = 1; // store session data
//echo "Pageviews = ". $_SESSION['views']; //retrieve data
print_r($_SESSION);
?>
will show the session Array ( [views] => 1 )
Then you can redirect to any other page and put the same print_r($_SESSION) in that particular redirected page, to find whether session have been set to that page.
Thanks
JOE
So you can set the session
<?php
session_start();
$_SESSION['views'] = 1; // store session data
//echo "Pageviews = ". $_SESSION['views']; //retrieve data
print_r($_SESSION);
?>
will show the session Array ( [views] => 1 )
Then you can redirect to any other page and put the same print_r($_SESSION) in that particular redirected page, to find whether session have been set to that page.
Thanks
JOE
-
salehalatif
- Forum Newbie
- Posts: 9
- Joined: Wed Jan 28, 2009 12:03 am
Re: Cookie not set in my application
Yes cookie is set
but in application that error is still.
but in application that error is still.
Re: Cookie not set in my application
Ok seriously, everyone who has posted in this thread has not used the PHP code tags.
I would encourage all of you to review the forum guidelines.
I would encourage all of you to review the forum guidelines.
-
jothirajan
- Forum Commoner
- Posts: 69
- Joined: Tue Jan 27, 2009 12:06 am
Re: Cookie not set in my application
?????
What type of error you are getting
What type of error you are getting
-
salehalatif
- Forum Newbie
- Posts: 9
- Joined: Wed Jan 28, 2009 12:03 am
Re: Cookie not set in my application
@astions -> Sorry
@jothirajan -> Error "Cookie Not Created ";
But it redirect to Home.php with uid value
but when i click to further pages it & show an ERROR:
Either your session has expired |OR| you are not logged in
@jothirajan -> Error "Cookie Not Created ";
But it redirect to Home.php with uid value
but when i click to further pages it & show an ERROR:
Either your session has expired |OR| you are not logged in
-
salehalatif
- Forum Newbie
- Posts: 9
- Joined: Wed Jan 28, 2009 12:03 am
Re: Cookie not set in my application
any idea?