php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19882 Nonfunctional session_decode()
Submitted: 2002-10-12 18:51 UTC Modified: 2002-10-13 01:35 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: matt at dfstudios dot com Assigned:
Status: Not a bug Package: Session related
PHP Version: 4CVS-2002-10-12 OS: Redhat 7.2
Private report: No CVE-ID: None
 [2002-10-12 18:51 UTC] matt at dfstudios dot com
This is probably related to the issue described in http://bugs.php.net/bug.php?id=19877. 

In 4CVs-2002-10-12 session_decode() appears to be non-functional. The function simply does nothing - no values are returned and no variables are set. I have verified that I'm passing the function a properly formatted session data string. 

register_globals is on. Here's my configure line:
./configure --with-mysql --with-apache=/root/apache_1.3.27 --enable-track-vars --enable-trans-sid --enable-sigchild --enable-ftp --enable-debug --enable-sockets

I'm using the CVS version because I was experiencing the session_decode crash bug with version 4.2.x (see previous bug report - URL given above). Perhaps these two issues are related?

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-12 19:49 UTC] iliaa@php.net
Did you initialize a session by calling session_start() before calling session_decode() ?
 [2002-10-12 20:02 UTC] matt at dfstudios dot com
Yes, session_start() is called in another page. I store the session data string in a local database and pass the session ID from page to page. 

I should note that I've used these scripts with no problems for MONTHS, I began experiencing crashes yesterday, for no reason I can identify, and it's been all downhill from there.
 [2002-10-12 20:09 UTC] iliaa@php.net
But does that page that calls session_decode call session_start itself?
 [2002-10-12 21:42 UTC] sniper@php.net
I closed the other report since it really is same issue.
Please add a short simple script which clearly shows the
problem you're having. And all in one single script, thank you.

 [2002-10-12 23:21 UTC] matt at dfstudios dot com
To answer iliaa's question: No, session_start is called on a separate page. 

This is really weird, I made up the following script as per Sniper's request:

<?
session_start();
session_register('testvar');
$testvar = "test";
$data = session_encode();
$testvar = "false";
session_decode($data);
echo("$testvar");
?>

Strangely, THIS script works fine (if it was 'broken', it should output "false", while it in fact prints "test"). 

However, I've made another script where the error is replicated:
www.dfstudios.com/session_test.php

Here's the source:

session_test.php------
<?
session_start();
session_register('testvar');
$testvar = "test";

$data = session_encode();
echo("testvar is \"$testvar\", and has been encoded: $data <br><br>");
?>
<a href="session_test2.php?<? echo("$data"); ?>>Click here for page two</a>

session_test2.php------
<?
session_decode($QUERY_STRING);
echo("testvar is \"$testvar\", and the string used for decoding is $QUERY_STRING <br><br>");
?>

Notice how $testvar is properly set on the first page and encoded properly, but in the second page $testvar is null. It seems that if session_start and session_decode are called in separate pages the decode function fails.
 [2002-10-13 01:35 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Unless you do session_start() before doing session_decode(), the latter will fail to produce valid data. You MUST call session start before calling session_decode.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 14 16:01:34 2025 UTC