session_module_name

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

session_module_name

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

do you have auto session start? do you still have the session cookie in your browser from previous loads?
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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..
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

if session_load() is being called twice, yet, it is likely the issue.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post 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

Code: Select all

Seesion_Load();
Will this invoke Session_Load twice ?

Thanks
Last edited by anjanesh on Thu Dec 22, 2005 1:08 am, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it shouldn't, as each is a seperate page request...
Post Reply