Welcome Guest, Not a member yet? Register   Sign In
WebFarms and Sessions
#2

[eluser]darkhouse[/eluser]
Unfortunately, passing the session id in the url is the only way, but you can hide it by doing a redirect. I don't know how your "web farm" is setup, but maybe you can have a library that manages the switching between the different sites, something like this:

Code:
class Webfarm {

   var $CI;

   function Webfarm(){
      $this->CI =& get_instance();
      $this->CI->load->helper('cookie');
   }

   function force($domain){      
      $cookie = get_cookie('PHPSESSID');
      redirect($domain.'/xfer/'.$cookie.$this->CI->uri->uri_string());
   }

}

So then you can put into any controller, this:

Code:
class Some_page extends Controller {

   function Some_page(){
      parent::Controller();
      $this->load->library('webfarm');
      $this->webfarm->force('somedomain.com');
   }

   function index(){
      $this->load->view('page');
   }

}

Now, in the webfarm library, in the redirect, you'll see it passing the session id and the uri string to a controller called 'xfer', which would be this:

Code:
class Xfer extends Controller {

   function Xfer(){
      parent::Controller();
   }
    
   function index($sess_id){
      $args = func_get_args();
      array_shift($args);
      $path = implode('/', $args);
      $this->load->helper('cookie');
      set_cookie('PHPSESSID', $sess_id);
      redirect($path);
   }
    
}

So there's just a couple other things to do, add a route for the xfer index:

Code:
$route['xfer/(:any)'] = "xfer/index/$1";

And change the base_url in the config file to this:

Code:
$config['base_url'] = (isset($_SERVER['HTTPS']) ? 'https' : 'http')."://".$_SERVER['HTTP_HOST'].'/';

This is untested, but I think it'll work. I did something similar on a site to transfer sessions between http and https.


Messages In This Thread
WebFarms and Sessions - by El Forum - 09-23-2009, 05:02 AM
WebFarms and Sessions - by El Forum - 09-23-2009, 05:47 AM
WebFarms and Sessions - by El Forum - 09-23-2009, 06:07 AM
WebFarms and Sessions - by El Forum - 09-23-2009, 06:22 AM
WebFarms and Sessions - by El Forum - 09-23-2009, 06:46 AM
WebFarms and Sessions - by El Forum - 09-23-2009, 07:43 AM
WebFarms and Sessions - by El Forum - 09-23-2009, 07:46 AM
WebFarms and Sessions - by El Forum - 09-23-2009, 07:55 AM
WebFarms and Sessions - by El Forum - 09-23-2009, 12:05 PM
WebFarms and Sessions - by El Forum - 09-23-2009, 02:01 PM
WebFarms and Sessions - by El Forum - 09-23-2009, 02:27 PM
WebFarms and Sessions - by El Forum - 09-24-2009, 01:32 AM
WebFarms and Sessions - by El Forum - 09-24-2009, 04:02 AM
WebFarms and Sessions - by El Forum - 09-24-2009, 04:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB