Welcome Guest, Not a member yet? Register   Sign In
CI sessions and AJAX
#1

[eluser]vickel[/eluser]
I've a setup, where the CI session table is updated correctly whenever I call a AJAX function, but the session cookie doesn't get updated. Is there a work around?

thanks
#2

[eluser]Ochetski[/eluser]
Can you put 2 examples here?


1st: how did you set the session data?
2nd: how do you get the data?
#3

[eluser]vickel[/eluser]
Hi Ochetsky,

session data is set on controller level when a user performs a login, which obvoiusly is a server side call. It updates correctly both, the database and the session cookie. Once you are logged in, all "links" are ajax calls, the database value of the session is updated correctly, but the cookie doesn't read correctly (it's still the value when we logged in)

I'm using a little javascript which checks the session cookie value every 15"; (it displays correctly if I call any controller function by typing in the url!)
#4

[eluser]Ochetski[/eluser]
Accessing the same pages without ajax after logged, directly, does work?
#5

[eluser]vickel[/eluser]
Yes, all works, but the session cookie update at a ajax call
#6

[eluser]Ochetski[/eluser]
Im pretty confused with your thread, but looking for "session ajax" found this that maybe can help: http://ellislab.com/forums/viewthread/176665/
#7

[eluser]vickel[/eluser]
I've to reformulate my thread, sorry: I've just done a further test and the session cookie actually updates correctly as well. I'm having trouble to read it (all 15'') with my client side script.
#8

[eluser]Ochetski[/eluser]
I guess you make a ajax request to check the session every 15s.

When you try to get the content the session is erased?
Or, you don't know how to make this JS code?
#9

[eluser]vickel[/eluser]
Hi Ochetski, thanks for your time

what I want to do is to check if a user has been inactive for x seconds. In case of inactivity I show a warning dialog box, which will log out the user in case he is not responding.

what I have is an ajax rich application and CI framework. After logging into the aplication part of the website I'm loading only one view. In this view I have a javascript which checks every x-seconds how the value of the session cookie is. And there I have my problems. Maybe I'm checking the wrong way?

I use:

Code:
document.getElementById('txt2').value='<?=$this->session->userdata('last_activity')?>';

which should write the cookie value into a div with the id 'txt2'
#10

[eluser]Ochetski[/eluser]
Looks like you are requesting it just like must be. Are you setting last_activity something like this way bellow?

Code:
$sess_data = array(
    'last_activity' => '123123123'
);
$this->session->set_userdata($sess_data);




Theme © iAndrew 2016 - Forum software by © MyBB