php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1988 <?=sid?> doesn't reflect session_name("newname") change
Submitted: 1999-08-07 13:25 UTC Modified: 1999-08-07 13:29 UTC
From: kovacsp at egr dot uri dot edu Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 4.0 Latest CVS (07/08/1999) OS: Linux 2.2.9
Private report: No CVE-ID: None
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
14 - 4 = ?
Subscribe to this entry?

 
 [1999-08-07 13:25 UTC] kovacsp at egr dot uri dot edu
<?
session_start();
        echo "\nSession name: " . session_name();
        echo "\nSetting session name to blah";
session_name("blah");
        echo "\nSession name now: " . session_name();
?>        
        
<?=sid?>

Produces this output:

Session name: PHPSESSID
Setting session name to blah
Session name now: blah
PHPSESSID=8beb119ba14466d03261957ebea8d853

PHP4 running as dynamic apache module compiled with the following parameters:
./configure  --with-apxs=/usr/bin/apxs --with-mysql

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-08-07 13:29 UTC] sas at cvs dot php dot net
Once a session is started, either explicitly through session_start() or implicitly through session_register(), the name of the session cannot be changed anymore. More correctly, the name change is not reflected in anything which is performed during session start (e.g. defining sid).

Therefore put session_name() before session_start() and you are fine.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 05:01:33 2025 UTC