Jump to content
Sign in to follow this  
x-plosiv

phpbb: Error creating new session

Recommended Posts

hi...i hope you understand me...my english is not so good. :-(

 

i have installed the phpbb constrib 2.0.8a

 

and by 90% of the useres is working without any problems.

 

may 10% have problems:

 

here's the error code...i hope you can help me...thanx

 

phpBB : Critical Error

 

Error creating new session

 

DEBUG MODE

 

SQL Error : 1062 Duplicate entry 'd32fbb0af2120d791fd35229612bc586' for key 1

 

INSERT INTO phpbb_sessions (session_id, session_user_id, session_start, session_time, session_ip, session_page, session_logged_in) VALUES ('d32fbb0af2120d791fd35229612bc586', 2, 1091000488, 1091000488, 'c186fe73', 5, 1)

 

Line : 80

File : /home/XXXXX/public_html/includes/modules/phpbb2/includes/sessions.php

Share this post


Link to post
Share on other sites

Hi

 

I have the same problem, and I've been checking on the forum, it seems to be a configuration.php problem... but on my case none of the solutions found have solved the problem at 100%

 

Try this:

 

1) Check that all keys on the Sessions menu in admin are set to FALSE (I had the spiders one set to TRUE, changed it to FALSE and the problem now appears less on my site)

2) Change sessions stored from SQL to FILES (or viceversa) - in my case, a new arror appeared, so, didn't work for me...

3) Check your configuration.php file and don't leave empty any field, check that the COOKIE ones have correct paths - mine is correct... I think.

 

Anyone else can share some knowledge?

 

Thanks


Juan Jose Velez - Trunks

trunks@gamefan.com.mx

Share this post


Link to post
Share on other sites

thanks for you help

 

you meen the sessions in the shop or in the phpbb?

 

now i have more problems with the php 5..is there any update for phpbb and php 5.0 an osc?

 

thanks

Share this post


Link to post
Share on other sites

I mean sessions in phpbb, no idea about the php 5...


Juan Jose Velez - Trunks

trunks@gamefan.com.mx

Share this post


Link to post
Share on other sites

I don't know if this can help you but here is what I found:

 

the reason that this error happens is becuase of this "if" statement (in catalog/includes/modules/phpbb2/includes/sessions.php) right here:

 

if ( !$db->sql_query($sql) || !$db->sql_affectedrows() )

 

for some reason the update query works fine if you are logged on but "!$db->sql_affectedrows()" doesn't think that you updated anything.

 

so what i did to fix this is:

 

changed the original code: (approx line 73 to line 82) of

 

	if ( !$db->sql_query($sql) || !$db->sql_affectedrows() )
{
 $sql = "INSERT INTO " . SESSIONS_TABLE . "
	 (session_id, session_user_id, session_start, session_time, session_ip, session_page, session_logged_in)
	 VALUES ('$session_id', $user_id, $current_time, $current_time, '$user_ip', $thispage_id, $login)";
 if ( !$db->sql_query($sql) )
 {
	 message_die(CRITICAL_ERROR, 'Error creating new session', '', __LINE__, __FILE__, $sql);
 }
}

 

to this new code:

 

	if ( !$db->sql_query($sql) || !$db->sql_affectedrows() )
{

 $sql = "INSERT INTO " . SESSIONS_TABLE . "
	 (session_id, session_user_id, session_start, session_time, session_ip, session_page, session_logged_in)
	 VALUES ('$session_id', $user_id, $current_time, $current_time, '$user_ip', $thispage_id, $login)";
 if ( !$db->sql_query($sql) )
 {
 // delete session that is the same
	 $sql = "DELETE FROM phpbb_sessions WHERE session_id = \"$session_id\"";
	 $db->sql_query($sql);


	 $sql = "INSERT INTO " . SESSIONS_TABLE . "
     (session_id, session_user_id, session_start, session_time, session_ip, session_page, session_logged_in)
     VALUES ('$session_id', $user_id, $current_time, $current_time, '$user_ip', $thispage_id, $login)";
	 if ( !$db->sql_query($sql) )
	 {
   message_die(CRITICAL_ERROR, 'Error creating new session', '', __LINE__, __FILE__, $sql);
	 }
 }
}

 

what this does is check to see if there is a session that exists in the phpbb_sessions table. if so then it deletes it from this table. Then it tries to do the insert again. If you get another insert problem you get the critical error. If not then we are fine.

 

Though there is a 1 in 6.3340286662973277706162286946812e+49 chance that the session id may be recreated again while someone is logged in at that same time I assume it will boot the other person off becuase it deletes their session (but since I am a gambler I am willing to take that chance). In the off chance that this does happen I am assuming since the session table contains the session_user_id number this should reduce any risk of anything else funny happening. Finally if someone does encounter something weird while they are using the bbs (that is they are getting kicked off becuase of their session id) and they actually do contact the webmaster. just tell them to clear their cookies and a new session id will be created when they log in.

 

I have worked with oscommerce for a while now but have not worked with phpbb. So if there are any flaws with my programming or any comments, please feel free to post a reply so I can fix my code. Anyway I hope this helps all those who use this contribution.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×