php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48191 Passing the Session ID won't work after disable session.use_cookies
Submitted: 2009-05-08 14:19 UTC Modified: 2009-05-12 02:01 UTC
From: jens at dutzi dot me Assigned: fb-req-jani (profile)
Status: Not a bug Package: Session related
PHP Version: 5.3.0RC2 OS: Debian (lenny)
Private report: No CVE-ID: None
 [2009-05-08 14:19 UTC] jens at dutzi dot me
Description:
------------
When forcing PHP to not use cookies for sessions, PHP doesn't recognize the existing session. Instead it will create a new one. Session files will be created as expected.

The Bug can be reproduced with:
1.) ini_set('session.use_cookies', 0); in the php-code
and
2.) session.use_cookies = 0; in php.ini

The following sample code is identical to http://www.php.net/manual/en/session.idpassing.php

Reproduce code:
---------------
<?php
// Disable Cookie-Usage
ini_set('session.use_cookies', 0);

// Start the session
session_start();

if (empty($_SESSION['count'])) {
	$_SESSION['count'] = 1;
} else {
	$_SESSION['count']++;
}
?>

<p>Hello visitor, you have seen this page <?php echo $_SESSION['count']; ?> times.</p>
<p>To continue, <a href="test.php?<?php echo htmlspecialchars(SID); ?>">click here</a>.</p>

Expected result:
----------------
On the first run, a new session should be created with $_SESSION['count'] = 1. On everey reload $_SESSION['count'] should be increased. (s.a. example #1 at http://www.php.net/manual/en/session.idpassing.php)

Actual result:
--------------
On every run, PHP creates a new session with $_SESSION['count']=1.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-08 21:31 UTC] jani@php.net
You must also check the "session.use_only_cookies" directive and set 
that also to 0 to be able to really use cookies. 
 [2009-05-11 15:11 UTC] jens at dutzi dot me
thanks - your hint about "session.use_only_cookies" was the solution.

It seems, the default-setting for this configuration option had been changed from off to on:

[jens@linux www]# php529/bin/php -i |grep session.use_only_cookies  
session.use_only_cookies => Off => Off

[jens@linux www]# php530/bin/php -i |grep session.use_only_cookies  
session.use_only_cookies => On => On
 [2009-05-12 02:01 UTC] jani@php.net
Yes, and this is not a bug. :)
 [2010-03-17 10:04 UTC] vijay dot gupta2021 at gmail dot com
good scripta
solve my very long problem
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 14 20:01:31 2024 UTC