Save your session data to a database with session_set_save_handler().
UPDATE
Efficiency wise it would be very mininal, the difference from reading a text file to querying a database (presumably using an existing connection).
Some example code (simplified from what I use)
class Session {
public function __construct() {
session_start();
$this->clean();
}
public function __destruct() {
session_write_close();
}
public function open() {
return TRUE;
}
public function close() {
return TRUE;
}
public function read($id) {
global $Database;
if ($Database->select('session_data FROM sessions WHERE session_id="%s"', $id)) {
list($data) = $Database->fetch(MYSQL_NUM);
return $data;
} else {
return '';
}
}
public function write($id, $data) {
global $Database;
return $Database->replace('sessions SET session_id="%s", session_data="%s", session_updated=%d', array($id, $data, time()));
}
public function destroy($id) {
global $Database;
$_SESSION = array();
return $db->delete('sessions WHERE session_id="%s"', $id);
}
public function clean($expire = 600) {
global $Database;
$Database->delete('FROM sessions WHERE session_updated<%d', $time - $expire);
return TRUE;
}
}
// Declare the functions to use:
session_set_save_handler(array('Session', 'open'), array('Session', 'close'), array('Session', 'read'), array('Session', 'write'), array('Session', 'destroy'), array('Session', 'clean'));
$Session = new Session;
The you can read/write to the session data using $_SESSION['name'] = data;
in the usual technique.