php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22639 Session Cookies
Submitted: 2003-03-11 14:47 UTC Modified: 2003-03-12 01:21 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: mail at sethknorr dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 4.3.1 OS: Unix
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mail at sethknorr dot com
New email:
PHP Version: OS:

 

 [2003-03-11 14:47 UTC] mail at sethknorr dot com
print_r($_COOKIE);
Does not print Session cookies. IE from another global source.

example in Perl if you use the variable it shows all cookies including session ones:
$ENV{'HTTP_COOKIE'}

print_r($_COOKIE);
Will show the same variables as $ENV{'HTTP_COOKIE'} minus any session cookies. I looked through this site but saw no documentation on this and am thinking it is posibly a bug in PHP.

Thanks for your attention to this.

Seth Knorr

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-03-11 20:42 UTC] sniper@php.net
Not a bug. (define 'session cookie' ?)

 [2003-03-12 00:07 UTC] mail at sethknorr dot com
What I mean by session cookie is one that is set but then deleted once you would leave that web site.

Example If I where to use the Perl code below to set a cookie, it would be read in perl with the variable $ENV{'HTTP_COOKIE'} but not with print_r($_COOKIE);
#################
#Start Perl Code
#################
$user = "test";
$pass = "pass";
$cookie = &SetCookie("susername", $user, 0);
print $cookie;
$cookie = &SetCookie("spassword", $pass, 0);
print $cookie;

sub SetCookie() {
  my ($name,$value,$expires,$path,$domain) = @_;

  $name=&CookieRE($name);
  $value=&CookieRE($value);

  $expires=$expires * 24 * 60 * 60;

  my $expire_at=&CookieDate($expires);
  my $namevalue="$name=$value";

  my $COOKIE="";

  if ($expires != 0) {
     $COOKIE= "Set-Cookie: $namevalue; expires=$expire_at; ";
  }
   else {
     $COOKIE= "Set-Cookie: $namevalue; ";
   }
  if ($path ne ""){
     $COOKIE .= "path=$path; ";
  }
  if ($domain ne ""){
     $COOKIE .= "domain=$domain; ";
  }
   
  $COOKIE .= "\n";

  return $COOKIE;
}


sub CookieDate() {
  my ($seconds) = @_;

  my %mn = ('Jan','01', 'Feb','02', 'Mar','03', 'Apr','04',
            'May','05', 'Jun','06', 'Jul','07', 'Aug','08',
            'Sep','09', 'Oct','10', 'Nov','11', 'Dec','12' );
  my $sydate=gmtime(time+$seconds);
  my ($day, $month, $num, $time, $year) = split(/\s+/,$sydate);
  my    $zl=length($num);
  if ($zl == 1) { 
    $num = "0$num";
  }

  my $retdate="$day $num-$month-$year $time GMT";

  return $retdate;
}


sub CookieRE() {
  my($retval) = @_;

  $retval=~s/\;//;
  $retval=~s/\=//;

  return $retval;
}
#################
#End Perl Code
#################

Where as for example if I used this java script code to set cookies, will apear in both the $ENV{'HTTP_COOKIE'} and with print_r($_COOKIE); 

<SCRIPT LANGUAGE = "JavaScript">
<!-- 


function setCookie(name, value, expires) {
document.cookie = name + "=" + escape(value) + "; path=/" +
((expires == null) ? "" : "; expires=" + expires.toGMTString());
}


function getValue(element) {
var value = getCookie(element.name);
    if (value != null) element.value = value;
}

function setValue(element) {
setCookie(element.name, element.value, exp);
}

var exp = new Date();                                   
exp.setTime(exp.getTime() + (1000 * 60 * 60 * 24 * 31));

function delCookie(name) {
document.cookie = name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT" +  "; path=/";
}

//-->

</SCRIPT>

<form OnSubmit = "setValue(document.form.username) + setValue(document.form.password);">
Etc...


Hopefully that maks sense, I know the last thing you want to do is read perl code but it will give you an example of what I mean.


Seth
 [2003-03-12 01:21 UTC] sniper@php.net
Still not PHP bug. (try come up with some PHP code, we don't understand anything else :)


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Dec 06 10:00:01 2025 UTC