You really shouldn't comment out or amend wp_unregister_globals. Checkout http://silvermapleweb.com/using-the-php-session-in-wordpress/ for examples of how to achieve sessions in Wordpress without messing with wp_unregister_globals.
I use this and it works a treat:
add_action('init', 'myStartSession', 1);
function myStartSession() {
if(!session_id()) {
session_start();
}
}
I would also consider storing your session data in the database rather than in files, particularly as you are in a shared server environment. Anyone else on that server could potentially access your sites session data and take over a users session.
In my most recent plugin I created a new table in the Wordpress database to store session data, then use set_session_save_handler to change the behaviour. So my start session script became something like this:
add_action('init', 'myStartSession', 1);
function myStartSession() {
if(!session_id()) {
session_set_save_handler('open_session', 'close_session', 'read_session', 'write_session', 'destroy_session', 'clean_session');
session_start();
}
}
add_action( 'session_gc', 'session_gc');
if ( ! wp_next_scheduled( 'session_gc' ) )
{
wp_schedule_event( time(), 'hourly', 'session_gc' );
}
function open_session()
{
return true;
}
function close_session()
{
return true;
}
function read_session($sessionid)
{
global $wpdb;
$session_table_name = $wpdb -> prefix . "sessions";
$query = $wpdb->prepare(
"SELECT data FROM $session_table_name
WHERE id = %s",
$sessionid);
$result = $wpdb -> get_var($query);
if ($result)
{
return $result;
} else
{
return '';
}
}
function write_session($sessionid,$data)
{
global $wpdb;
$session_table_name = $wpdb -> prefix . "sessions";
$rowsaffected = $wpdb->replace(
$session_table_name,
array(
'id' => $sessionid,
'data' => $data
),
array(
'%s',
'%s'
));
return true;
}
function destroy_session($sessionid)
{
global $wpdb;
$session_table_name = $wpdb -> prefix . "sessions";
$rowsaffected = $wpdb->delete($session_table_name,array('id' => $sessionid),array('%s'));
$_SESSION = array();
return true;
}
function clean_session($expire)
{
global $wpdb;
$session_table_name = $wpdb -> prefix . "sessions";
$wpdb->query(
$wpdb->prepare(
"DELETE FROM $session_table_name
WHERE DATE_ADD(last_accessed, INTERVAL %d SECOND) < NOW()",
$expire
)
);
return true;
}
function session_gc() {
global $wpdb;
$session_table_name = $wpdb -> prefix . "sessions";
$query = "DELETE FROM $session_table_name WHERE last_accessed < date_sub(CURRENT_TIMESTAMP(), INTERVAL 1 DAY)";
$wpdb->query($query);
}
See http://www.stormyfrog.com/using-wpdb-outside-wordpress/ for tips on accessing the $wpdb class from outside Wordpress. You could simply include wp-load.php, then I think you would get the session behaviour for free as I'm pretty sure the init hook comes in after wp-load.php, the downside to that of course is you put the overhead of loading Wordpress into your own pages which you may not want.