I try to describe. First of all, i have to throw my first message to trash bin. Cause i wasn’t thinking this through. I’m using jQuery on my site, and when it makes AJAX requests, it of course loads controller again, and can’t access on those variables. So i have to store some hidden data in hidden inputs.
But i’ll explain how i managed to store data and how my site works atm. So my little ongoing project is used to create simple images, like banners. When user is visiting first time, my site creates unique id what is stored to session. Then it makes default background image and default text image to TEMP folder with GD and stores path’s, filename’s, width, height, colors, and all default stuff to MySQL temp table. Row ID is same as session id.
So next time when user is visiting site and if session is found, it uses those images and values from SQL, and doesn’t create them again. If user is changing input values, jQuery saves them to MySQL temp table onchange.
One of my “problem” ATM is that when user is in “create_image” controller, and he want’s to upload own background image. I’m not using jQuery to upload file (now i’m thinking should i?), but i’m using basic form upload that calls “upload_image” controller. But if there is error or not, i’ll have to again call MySQL to get all previous data back to “create_image” controller.
This isn’t problem, but i think that this could get quite messy, cause my current aproach is like this:
if ( $this->image_model->is_session_found( $this->session->userdata('example') ) )
$query = $this->db->get_where('temp_sessions', array('id' => $this->session->userdata('example')), 1);
foreach ($query->result() as $row)
$data['temp_text_path'] = $row->temp_text_path;
$data['temp_bg_path'] = $row->temp_bg_path;
$data['temp_text_www'] = $row->temp_text_www;
$data['temp_text_width'] = $row->temp_text_width;
$data['temp_text_height'] = $row->temp_text_height;
$data['temp_bg_www'] = $row->temp_bg_www;
$data['temp_bg_width'] = $row->temp_bg_width;
$data['temp_bg_height'] = $row->temp_bg_height;
$data['image_string'] = $row->image_string;
$data['font_color'] = $row->font_color;
$data['font_size'] = $row->font_size;
$template_data = array(
'title' => 'Create counter',
'heading' => 'Create counter',
'content' => $this->load->view('create_counter', $data, TRUE)