MyBB Community Forums

Full Version: session_save_path before start_session
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I want to add session.save_path before the start session of mybb forum. But i cant find the code (session_start). Please help.
Hi xkevin,
Have you checked plugin hooks ?
http://docs.mybb.com/1.8/development/plugins/hooks/
If it's not than probably you can add custom code.
I don't know how to use that. But I am thinking to add session_start code. But where do i put this? 
I tried looking every file and I found something maybe related in creating a session.

First in global.php [line 51]
// Create session for this user
require_once MYBB_ROOT.'inc/class_session.php';
$session = new session;
$session->init();
$mybb->session = &$session;

$mybb->user['ismoderator'] = is_moderator('', '', $mybb->user['uid']);

second is in class_session.php [line 466]
function create_session($uid=0)
	{
		global $db;
		$speciallocs = $this->get_special_locations();
		
		ini_set('session.save_path',realpath(dirname($_SERVER['DOCUMENT_ROOT']) . '/site_sessions'));

		// If there is a proper uid, delete by uid.
		if($uid > 0)
		{
			$db->delete_query("sessions", "uid='{$uid}'");
			$onlinedata['uid'] = $uid;
		}
		// Is a spider - delete all other spider references
		else if($this->is_spider == true)
		{
			$db->delete_query("sessions", "sid='{$this->sid}'");
		}
		// Else delete by ip.
		else
		{
			$db->delete_query("sessions", "ip=".$db->escape_binary($this->packedip));
			$onlinedata['uid'] = 0;
		}

		// If the user is a search enginge spider, ...
		if($this->is_spider == true)
		{
			$onlinedata['sid'] = $this->sid;
		}
		else
		{
			$onlinedata['sid'] = md5(uniqid(microtime(true), true));
		}
		$onlinedata['time'] = TIME_NOW;
		$onlinedata['ip'] = $db->escape_binary($this->packedip);
		
		$onlinedata['location'] = $db->escape_string(substr(get_current_location(), 0, 150));
		$onlinedata['useragent'] = $db->escape_string(my_substr($this->useragent, 0, 100));
		
		$onlinedata['location1'] = (int)$speciallocs['1'];
		$onlinedata['location2'] = (int)$speciallocs['2'];
		$onlinedata['nopermission'] = 0;
		$db->replace_query("sessions", $onlinedata, "sid", false);
		$this->sid = $onlinedata['sid'];
		$this->uid = $onlinedata['uid'];
	}
MyBB doesn't use PHP sessions hence there is no session_start().
First of all: What do you need?
What i need is to save session. For sso purpose.
(2016-04-07, 09:11 AM)StefanT Wrote: [ -> ]MyBB doesn't use PHP sessions hence there is no session_start().

Is it possible to add customized code for sessions? As the user log in ,session will be save in a folder using session_save_path.
It is possible if you edit the file you mentioned - inc/class_session.php