[eluser]St0neyx[/eluser]
Hi,
I have this problem with the session and i can’t figure it out.
I have this controller that handles multiple form steps:
Stripped a lot of code (validation, setters, getters, etc), but this is basically what happens
Code:
function add_article($page, $mode=new, $id = null)
{
// some validating
switch ($page)
{
case 'step_one':
$this->session->set_userdata('step_one_progress', 'started');
if (this->input->post('step_one'))
{
// set some form validation
if ($this->form_validation->run() == false)
{
$this->load->view('templates/step_one.php', $data);
}
else
{
$this->session->set_userdata('step_one_progress', 'finished');
redirect($data->next_page);
}
}
else
{
// no post so show form
$this->load->view('templates/step_one.php', $data);
}
break;
case 'step_two':
if ($this->session->userdata('step_one') == 'finished')
{
$this->session->set_userdata('step_two_progress', 'started');
if (this->input->post('step_two'))
{
if ($this->form_validation->run() == false)
{
$this->load->view('templates/step_two.php', $data);
}
else
{
$this->session->set_userdata('step_two_progress', 'finished');
redirect($data->next_page);
}
}
else
{
$this->load->view('templates/step_two.php', $data);
}
}
else
{
// previous step not yett finished, redirect back
redirect($data->previousPage);
}
break;
case 'step_three':
if ($this->session->userdata('step_two') == 'finished')
{
$this->session->set_userdata('step_three_progress', 'started');
if (this->input->post('step_three'))
{
if ($this->form_validation->run() == false)
{
$this->load->view('templates/step_three.php', $data);
}
else
{
$this->session->set_userdata('step_three_progress', 'finished');
redirect($data->next_page);
}
}
else
{
$this->load->view('templates/step_three.php', $data);
}
}
else
{
// previous step not yett finished, redirect back
redirect($data->previousPage);
}
break;
default:
redirect('/home');
break;
} // end switch
} // end controller
From step one to step two there is no session data lost.
But when i try to proceed to step three the progress var is lost, so it can't proceed because of the check on progress.
I turned debugging on to see what is happening, also added some extra logging.
Here is the result:
INFO - 2010-11-25 14:02:20 --> case step_two = finished
INFO - 2010-11-25 14:02:20 --> Session: Array
(
[session_id] => 9b68f61e252a062681760a9cd7716fd8
[ip_address] => 10.2.0.113
[user_agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) Ap
[step_one_progress] => finished
[step_two_progress] => finished
)
INFO - 2010-11-25 14:02:20 --> redirect: add_article/step_three/new/
DEBUG - 2010-11-25 14:02:20 --> Config Class Initialized
DEBUG - 2010-11-25 14:02:20 --> Hooks Class Initialized
DEBUG - 2010-11-25 14:02:20 --> URI Class Initialized
DEBUG - 2010-11-25 14:02:20 --> Router Class Initialized
DEBUG - 2010-11-25 14:02:20 --> Output Class Initialized
DEBUG - 2010-11-25 14:02:20 --> Input Class Initialized
DEBUG - 2010-11-25 14:02:20 --> XSS Filtering completed
DEBUG - 2010-11-25 14:02:20 --> XSS Filtering completed
DEBUG - 2010-11-25 14:02:20 --> XSS Filtering completed
DEBUG - 2010-11-25 14:02:20 --> Global POST and COOKIE data sanitized
DEBUG - 2010-11-25 14:02:20 --> Language Class Initialized
DEBUG - 2010-11-25 14:02:20 --> Loader Class Initialized
DEBUG - 2010-11-25 14:02:20 --> Config file loaded: config/qoop.php
DEBUG - 2010-11-25 14:02:20 --> Helper loaded: url_helper
DEBUG - 2010-11-25 14:02:20 --> Helper loaded: project_helper
DEBUG - 2010-11-25 14:02:20 --> Helper loaded: xsl_helper
DEBUG - 2010-11-25 14:02:20 --> Helper loaded: menu_helper
DEBUG - 2010-11-25 14:02:20 --> Helper loaded: message_helper
DEBUG - 2010-11-25 14:02:20 --> Helper loaded: breadcrumb_helper
DEBUG - 2010-11-25 14:02:20 --> Database Driver Class Initialized
DEBUG - 2010-11-25 14:02:20 --> Session Class Initialized
DEBUG - 2010-11-25 14:02:20 --> before session init, session is: Array
(
)
DEBUG - 2010-11-25 14:02:20 --> Helper loaded: string_helper
DEBUG - 2010-11-25 14:02:20 --> Encrypt Class Initialized
DEBUG - 2010-11-25 14:02:20 --> Session routines successfully run
DEBUG - 2010-11-25 14:02:20 --> after session init: Array
(
[session_id] => 9b68f61e252a062681760a9cd7716fd8
[ip_address] => 10.2.0.113
[user_agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) Ap
[step_one_progress] => finished
[step_two_progress] => started
)
For some reason the progress is reseted to started, but the code doesn't come there (else there would be an extra loggin line).
Is this an bug in the session (to much redirecting)?
any suggestions?