Page 1 of 1
session_module_name
Posted: Wed Aug 03, 2005 1:25 pm
by anjanesh
Im sometimes getting this msg :
Code: Select all
[03-Aug-2005 14:05:11] PHP Warning: session_module_name(): A session is active. You cannot change the session module's ini settings at this time. in /xxx/sessions.php on line 5
Line 5 is session_module_name("user");
Each page calls this block - I did include_once()
Code: Select all
session_module_name("user");
session_set_save_handler("Session_Open","Session_Close","Session_Read","Session_Write","Session_Remove","Session_GC");
session_start();
Eventhough a sessionid exists I would still need to overwrite the settings right ? Otherwise it'll write sessions to the default one files ! Im writing sessions to a MySQL db.
Any idea why this happens ?
Thanks
Posted: Wed Aug 03, 2005 5:16 pm
by feyd
do you have auto session start? do you still have the session cookie in your browser from previous loads?
Posted: Wed Aug 03, 2005 9:38 pm
by anjanesh
There is a possibility of existing sessionids as a results of not logging off etc.
Anyway, I did all the possible checks and if not valid
header("Location: login.php")
It seems code after header Location is still getting executed.
I just learnt that thats possible - placed an exit after all header Location - now it seems to be ok.
Thanks
Posted: Wed Aug 03, 2005 10:05 pm
by feyd
header calls don't stop the rest of the page from being run.. so it's pretty much always true that code after header is run..
Posted: Wed Aug 03, 2005 10:21 pm
by anjanesh
Inspite of fixing header();exit; still this msg is getting logged (of course this msg is never displayed even when display_error is On)
Code: Select all
PHP Warning: session_module_name(): A session is active. You cannot change the session module's ini settings at this time
What I have is index.php is
Code: Select all
if (isset($_POST['Username']))
{
Session_Load(); // User defined function that has the 3 lines in the 1st post.
// etc
header("Location:MyPage.php");exit;
}
else
{
// Something else
}
and in MyPage.php I have
Code: Select all
if (isset($PHPSESSID))
Session_Load();
Could this be the reason for the error ? There are another 2 which with the 1st one as well - they come in a block.
A session had already been started and
Cannot modify header information .
Is it because Session_Load is getting called twice ?
All this time I thought header Location is just like a Javascript redirect or a META REFRESH.
In this case does index.php and MyPage.php get executed in a single thread ?
Thanks
Posted: Wed Aug 03, 2005 10:58 pm
by feyd
if session_load() is being called twice, yet, it is likely the issue.
Posted: Wed Aug 03, 2005 11:12 pm
by anjanesh
feyd wrote:
if session_load() is being called twice, yet, it is likely the issue.
Yes. That I understand.
What I would like to know is if I have in
a.php
Code: Select all
Seesion_Load();
header("Location: b.php");
In b.php
Will this invoke Session_Load twice ?
Thanks
Posted: Thu Aug 04, 2005 12:02 am
by feyd
it shouldn't, as each is a seperate page request...