Read a coldfusion cookie with php?

Can php read a cookie writen in coldfusion? I have this code that is writen in coldfusion and needs to be translated to php but I want to read a cookie that was created from a coldfusion page made on the same server. Here is the code.
--------Coldfusion-------------
<cfif NOT IsDefined("COOKIE.staffID")>
      <cfoutput><font size="+3">Your cookie has expired, please login again by clicking <a href="../login.cfm">here</a>.</font></cfoutput>
      <cfabort>
</cfif>
-----------PHP------------
<?php
if (! array_key_exists("staffID",$_COOKIE)) {
   die('<font size="+3">Your cookie has expired, please login again by clicking <a href="../login.cfm">here</a>.</font>');
}
?>
LVL 1
lhaluskaAsked:
Who is Participating?
 
ncooConnect With a Mentor Commented:
On second thought:

<?php
if ($_COOKIE['staffID']==null) {
   die('<font size="+3">Your cookie has expired, please login again by clicking <a href="../login.cfm">here</a>.</font>');
}
?>
0
 
ncooCommented:
A cookie is just a cookie, like HTML is HTML it don't matter how it was made, it always is the same (if valid).


$cookie = $_COOKIE['value'];
0
 
ncooCommented:
<?php
if (!isset($_COOKIE['staffID'])) {
   die('<font size="+3">Your cookie has expired, please login again by clicking <a href="../login.cfm">here</a>.</font>');
}
?>
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
lhaluskaAuthor Commented:
I am getting this output from that last post.If it works nothing should show up on the page right.Sorry I am a newbie.

Notice: Undefined index: staffID in C:\Inetpub\wwwroot\ServiceRequest\admin\test.php on line 2
Your cookie has expired, please login again by clicking here
0
 
ncooCommented:
if ($_COOKIE['staffID']==null)
{
//This will happen if the cookie does not exist or if the cookie contains no data
}

OR

if (!isset($_COOKIE['staffID']))
{
//This will happen if the cookie does not exist
}
0
 
Brijesh ChauhanStaff IT EngineerCommented:
add to your coldfusion <cfcookie name="XXXX" expires="NEVER"> to ensure that your cookie variable does not expire, then you can access it using PHP.
0
 
lhaluskaAuthor Commented:
I added the expired = never. It still doesn't work.
0
 
ncooCommented:
Do this tell me what you get.
<?php
print_r($_COOKIE);
?>
0
 
lhaluskaAuthor Commented:
Array ( [EMAIL] => lhaluska@cup.com [PHONE] => +1 708 225 1996 [STAFFDEPT] => 5996 [STAFFID] => LHaluska [ASPSESSIONIDACDBDDSC] => FPMLDDHCEJOFPMHFGGMAAOPC [CFID] => 34325 [CFMAGIC] => 34325:80010565 [CFTOKEN] => 80010565 )
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.