|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5922 Output garbled when using sessions
Submitted: 2000-08-02 15:09 UTC Modified: 2000-08-03 13:01 UTC
From: juhl at eisenstein dot dk Assigned:
Status: Closed Package: Session related
PHP Version: 4.0.0 OS: Slackware Linux 7.0
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: juhl at eisenstein dot dk
New email:
PHP Version: OS:


 [2000-08-02 15:09 UTC] juhl at eisenstein dot dk

I have a very wierd problem with sessions (I suspect trans-sid is 

I try to open a file and read its contents into a variable to do som 
string magic on it before passing it to the client, but whenever I output 
the contents of the variable it turns up completely garbled in the 
The funny thing is that if I save the contents of the variable to a file 
instead of sending it to the client, then the saved file is OK. 
This only happens when I'm using sessions (both the build in ones and my 
own session handling functions), if I don't call session_start() then 
output is fine.

How the file is garbled is very different from one file to another, and 
if I just change a few lines, then completely new areas are messed up.
Below is a small program that shows the bug, and a dump of one file that 
is messed up by this procedure - that should make it possible for you to 

I have the following code:

$filename = "test.txt";
$f = fopen($filename, "r");
$contents = fread($f, filesize($filename));
echo $contents;

The file "test.txt" contains the following:

<table border="0" cellpadding="0" cellspacing="0" width="111px" height="141px">
                <td width="29" height="20"><img src="../images/menu_01.gif"></td>
      <td colspan="2" background="../images/menu_02.gif" width="82" height="20" valign="bottom"><a href="#">Login</a></td>
                <td width="29" height="16"><img src="../images/menu_03.gif"></td>
      <td colspan="2" background="../images/menu_04.gif" width="82" height="16" valign="bottom"><a href="#">Logout</a></td>
                <td width="29" height="16"><img src="../images/menu_05.gif"></td>
      <td colspan="2" background="../images/menu_06.gif" width="82" height="16" valign="bottom"><a href="#">PR </a></td>
                <td width="29" height="16"><img src="../images/menu_07.gif">
      <td colspan="2" background="../images/menu_08.gif" width="82" height="16" valign="bottom"><a href="#">B</a></td>
                <td width="29" height="16"><img src="../images/menu_09.gif"></td>
      <td colspan="2" background="../images/menu_10.gif" width="82" height="16" valign="bottom"><a href="#">P</a></td>
                <td width="29" height="16"><img src="../images/menu_11.gif"></td>
                <td colspan="2" background="../images/menu_12.gif" width="82" height="16" valign="bottom"><a href="#">Sp&oslash;rg</a></td>
                <td width="29" height="16"><img src="../images/menu_13.gif"></td>
                <td colspan="2" background="../images/menu_14.gif" width="82" height="16" valign="bottom"><a href="#">&nbsp;</a></td>
                <td width="29" height="25"><img src="../images/menu_15.gif" width="29" height="25"></td>
                <td width="61" height="25"><img src="../images/menu_16.gif" width="61" height="25"></td>
                <td width="21" height="25"><img src="../images/menu_17.gif" width="21" height="25" usemap="#lukMenu" border="0"

When running the code as above I get the following in Lynx:

[menu_01.gif]      Login
   [menu_03.gif]      Logout
   [menu_05.gif]      PR    
   [menu_07.gif] Login   
   [menu_03.gif]      Logout
   [menu_05.gif]      PR    
   [menu_07.gif]      B  
   [menu_09.gif] t????h@???? o@????DB(????h@???? o@??"#">Logout
   [menu_05.gif]      PR 
   [menu_07.gif]      B  
   [menu_09.gif]      P
   [menu_11.gif]      PR
   [menu_07.gif]      B
   [menu_09.gif]      P
   [menu_11.gif]      Sp?rg
   [menu_13.gif]      B    
   [menu_09.gif]      P
   [menu_11.gif]      Sp?rg
   [menu_15.gif] P     
   [menu_11.gif]      Sp?rg
   [menu_15.gif]      [menu_16.gif] [menu_17.gif] Sp?rg
   [menu_15.gif]      [menu_16.gif] Luk
   [menu_15.gif] [menu_16.gif] Luk

The correct output (as will be given if I remove session_start() ) is :

 [menu_01.gif] Login
   [menu_03.gif] Logout
   [menu_05.gif] PR    
   [menu_07.gif] B  
   [menu_09.gif] P
   [menu_11.gif] Sp?rg
   [menu_15.gif] [menu_16.gif] Luk

Could someone please tell me what's wrong here? 

Best regards,
Jesper Juhl

PS. I'm running PHP 4.0.0 on Slackware Linux 7.0, Apache 1.3.12


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-02 16:00 UTC]
could you please try latest CVS or snapshot

i did a complete rebuild of the trans-sid stuff
this weekend, hope it solved this one too
 [2000-08-03 13:01 UTC]
Just tried this PHP4 snapshot : php4-200008022345 and it now works perfectly with two pages I've tested. 

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Mar 22 23:04:45 2023 UTC