Welcome Guest, Not a member yet? Register   Sign In
Ajax request without extending session?
#7

Okay so I played around with some things and managed to make some progress, but still having one minor issue.

Using the files driver, I am able to read the session data using this:

PHP Code:
//Get session names
$cookie_name $this->config->item('sess_cookie_name');
$session_name get_cookie($cookie_name);
$file_path $this->config->item('sess_save_path');
$file_name $cookie_name $session_name;
$file $file_path $file_name;

//Load session data
if($session_name && file_exists($file)) {
    
$data file_get_contents($file_path $file_name);

    
session_name($cookie_name);
    
session_start();
    
session_decode($data);

    return 
true;


This manually gets the contents of the session file and loads it into the current session, so I can read it from $_SESSION. This works well, so that in my AJAX call I can check if $_SESSION is empty or doesn't have correct keys set etc.

The only problem is running session_start() manually like this, it is creating a new session file named sess_XXXXX, rather than the usual ci_session_XXXXX. I understand this is the default naming in PHP files driver, and CI files driver sets this manually to avoid conflicts - but my question is how can I get it to use ci_session instead of sess?

Obviously if I load and use the normal CI Session library, it'll do this, but it'll also extend the cookie/session expiry as well, which was my initial problem.

Anyone have any ideas? This isn't a major issue, but it's causing double the session files on the disk unnecessarily.

Thanks!
Reply


Messages In This Thread
RE: Ajax request without extending session? - by JayAdra - 06-28-2016, 06:43 PM



Theme © iAndrew 2016 - Forum software by © MyBB