Jump to content

session.save_path not set


mr_mind

Recommended Posts

Alright i dont know if this is correct but i have a function that i am implementing to read the session files and see who is online. The problem is "session_save_path()" returns null. I checked in the php.ini and it is remarked out, but the sessions work fine. What i think i need to do is find the default session save path and specify that in the php.ini and then try the function. if not just specify the absolute path in the function instead of using session_save_path(). My question is, what is the default session save path for php 5?

Link to comment
Share on other sites

alright well i fixed the problem of the session path not being set but now my function returns 0 users online all the time. Here it is:

 

<?php
function users_online() {
	if(is_dir(session_save_path())) {
		$users_online_max_time = 3;
		$users_online_handle = session_save_path();
		$users_online_count = 0;
		$users_online_files = glob($users_online_handle . "*");
		foreach($users_online_files as $users_online_file) {
			if($users_online_file != '.') {
				if($users_online_file != '..') {
					$script_time = time();
					$file_time = fileatime($users_online_file);
					if(($script_time - $file_time) < $users_online_max_time * 60) {
						$users_online_count++;
					}
				}
			}
		}
		return $users_online_count;
	}
	else {
		return session_save_path();
	}
}
print 'Online Users: ' . users_online(); 
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.