php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50602 Session doesn't work in php5
Submitted: 2009-12-29 08:19 UTC Modified: 2009-12-29 09:38 UTC
From: jansi_bosco at yahoo dot co dot in Assigned:
Status: Not a bug Package: Session related
PHP Version: 5.3.1 OS: Linux
Private report: No CVE-ID: None
 [2009-12-29 08:19 UTC] jansi_bosco at yahoo dot co dot in
Description:
------------
I am using php5 version. The script is doesn't work in php5. But its work under php4 fine. What may be the problem occurs? I search the page in my php info() file, The register_global is ON mode in Php4. 
But in the php5 the register_global is OFF.

In my site, there are the scripts are didn't work well. The file redirect to another page. But there is no data is retreived. The save_path also have a no value.  so I have created the sample page in my site whether the session is work or not.  But in my server side the session is not working well. I checked the php info file the register global is off

 Given below the example was I used. Its not working under php5.

Reproduce code:
---------------
 //session1.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
	<title>Untitled</title>
</head>

<body>

<?php
  session_start('mysession');
  class Cus{
    var $cusid;
    function newCus($cusid, $index){
      $this->cusid[$index] = $cusid;
    }
    function getCus(&$tmparray){
      for($i = 0; $i < count($this->cusid); $i++){
        $tmparray[$i] = $this->cusid[$i]; 
      }
    }
  }
  $customer = new Cus();
  $customer->newCus("Cliente 1",0);
  $_SESSION['customer'] = $customer;
  echo "<a href=\"./session2.php\">P?gina 2 de la sesi?n</a><br>";
  print_r($_SESSION);
?>

</body>
</html>

---------------------------------------------------------------------

 //session2.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
	<title>Untitled</title>
</head>

<body>

<?php
session_start();
  class Cus{
    var $cusid;
    function newCus($cusid, $index){
      $this->cusid[$index] = $cusid;
    }
    function getCus(&$tmparray){
      for($i = 0; $i < count($this->cusid); $i++){
        $tmparray[$i] = $this->cusid[$i]; 
      }
    }
  }
$_SESSION['customer']->getCus($tmparr);
print_r($tmparr);

session_unset();  
session_destroy();
?>

</body>
</html>




Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-29 09:38 UTC] derick@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

There are many things wrong here, but they are not bugs. Tip: can\'t run session_Start() after echo content (such as HTML).
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Dec 14 05:00:01 2025 UTC