[eluser]treeface[/eluser]
Hey jedd,
Thanks for the helpful response! My sincerest apologies for the ramble-of-thought that was my initial post. I'm used to other forums where the rule of the land is to edit your original post with an <b>edit</b> tag...my fault!
I am in the process of reading all of those threads, but in the meantime, here are some details about the problem...
1. Let's say there are two links on my website (sorry, it's currently live but admin-only, so I can't show it to you) side-by-side. When you are logged in (encrypted sessions using session table in DB for validation), if you click on one of them the browser (and this is any browser I've tried...Chrome, Firefox, Safari, IE) will start the get request to the server (which is located in California where I am also located, but this is on the internet, not a dev environment).
2. Before the browser departs from the original page with the two links, but after you've clicked the first link, you still have the ability to interact with the original page. During this time, if you click the second link (say) 200 milliseconds or less after the first one, it just goes to the second link with no problems. No session destruction at all.
3. If you click on the second link after 200 milliseconds but before the browser departs the original page, it will try to go to the second page, but somewhere along the way, the session will have been destroyed, thus redirecting me back to my login page.
I try to replicate this on other CI sites (like this forum, for example) and it doesn't, at first glance, seem to happen. So clearly it's something to do with what I'm doing wrong, but I don't know where to start looking (that is, after I get done reading those threads). Also, I should mention that I have a small extension to the CI_Session and CI_Router libraries that go like this:
Code:
/*
* Session Class Extension
*/
class MY_Session extends CI_Session {
/*
* Do not update an existing session on ajax calls
*
* @access public
* @return void
*/
function sess_update() {
if ( !isAjax() ){
parent::sess_update();
}
}
}
And this...
Code:
class MY_Router extends CI_Router {
var $error_controller = 'error';
var $error_method_404 = 'error_404';
function My_Router() {
parent::CI_Router();
}
// this is just the same method as in Router.php, with show_404() replaced by $this->error_404();
function _validate_request($segments) {
// Does the requested controller exist in the root folder?
if (file_exists(APPPATH.'controllers/'.$segments[0].EXT)) {
return $segments;
}
// Is the controller in a sub-folder?
if (is_dir(APPPATH.'controllers/'.$segments[0])) {
// Set the directory and remove it from the segment array
$this->set_directory($segments[0]);
$segments = array_slice($segments, 1);
if (count($segments) > 0) {
// Does the requested controller exist in the sub-folder?
if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].EXT)) {
return $this->error_404();
}
}
else {
$this->set_class($this->default_controller);
$this->set_method('index');
// Does the default controller exist in the sub-folder?
if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$this->default_controller.EXT)) {
$this->directory = '';
return array();
}
}
return $segments;
}
// Can't find the requested controller...
return $this->error_404();
}
function error_404() {
$segments = array();
$segments[] = $this->error_controller;
$segments[] = $this->error_method_404;
return $segments;
}
function fetch_class() {
// if method doesn't exist in class, change
// class to error and method to error_404
$this->check_method();
return $this->class;
}
function check_method() {
$class = $this->class;
if (class_exists($class)) {
if ($class == 'doc') {
return;
}
if (! in_array('_remap', array_map('strtolower', get_class_methods($class))) // don't check controllers using _remap()
&& ! in_array(strtolower($this->method), array_map('strtolower', get_class_methods($class)))) {
$this->class = $this->error_controller;
$this->method = $this->error_method_404;
include(APPPATH.'controllers/'.$this->fetch_directory().$this->error_controller.EXT);
}
}
}
}
Please let me know if you need any more info or anything at all. Thanks again for your help!