Welcome Guest, Not a member yet? Register   Sign In
Strange behaviour with Sessions DB
#1

[eluser]Unknown[/eluser]
Hi,
First time poster, I've only be using CodeIgniter for a few weeks.

My site uses Session and I've configured it to save information to the database to allow me to save larger amounts of user data.
The site also connects to a MySQL and MSSQL database to retrieve information for the user. The Session database is in the MySQL database and this part is working.

The logic of the site goes:
1. User searches for something, the search button is attached to some jQuery code which sends the search term to 2 functions in my controller.
2. Function 1 accesses the MSSQL database, gets the data, saves the query and the results of the query to the session and returns the query results to the View.
3. Function 2 does the exact same except it queries the MySQL database.

Function 1 code does this:
Code:
$this->session->set_userdata('get_function1_query',$lastquery);
$this->session->set_userdata('get_function1_result',$query->result_array());

Function 2 code does this:
Code:
$this->session->set_userdata('get_function2_query',$lastquery);
$this->session->set_userdata('get_function2_result',$query->result_array());

The problem is that the Function 1 code does not save the data to the session table. If I remove the Function 2 code then the Function 1 code works!

Lastly, The result sets of the queries is small. Even so I changed the datatype of the 'user_data' field in the ci_sessions table from TEXT to MEDIUMTEXT to allow more information to be stored there.

Can anyone help?

Thanks!
#2

[eluser]Unknown[/eluser]
Solved it using the CodeIgniter native session
http://codeigniter.com/wiki/Native_session

It appears that there are some issues with Sessions and jQuery in CodeIgniter
#3

[eluser]CroNiX[/eluser]
Sessions work just fine with jQuery with a slight mod (one line) to not regenerate the session ID if it's an ajax request. Every project I have ever done with CI uses both of them together. Also, if you turn query caching on, what you are doing above would be totally unnecessary (and a LOT faster).

Does it really make sense to store a query that you run and its result set...back into the database via session? You still need another query to retrieve the same data. Just run the query again, or use caching.




Theme © iAndrew 2016 - Forum software by © MyBB