Welcome Guest, Not a member yet? Register   Sign In
Simple Form Validation question!
#1

[eluser]arbme666[/eluser]
Hey all,

I'm new to CI and just have a quick question. After running form validation like below how do you call the validated and clean data.

Code:
set rules code...

if ($this->form_validation->run() == FALSE)
{
$this->load->view('login_form');

} else {

$username = $this->input->post('username');
$password = $this->input->post('password');

}

Would this be correct or am I just calling data that has not been validated.

Thanks
#2

[eluser]steelaz[/eluser]
Input will have clean data after you validated it, so it's safe to use:

Code:
$username = $this->input->post('username');
#3

[eluser]WanWizard[/eluser]
If the form validated succesfully, the values of the $_POST are updated with the result of the validation, so yes, your input has been validated (and cleaned if you asked it to).
#4

[eluser]arbme666[/eluser]
Thanks again for the quick reply.

One more question is there any way for the user to specify how long they want until the session cookie will expire?

A way of overriding the $config['sess_expiration'] so when the users login they can input say 30mins?

I have tried to destroy the session cookie and make a new one but with no luck. Maybe someone could point me to some links etc.

Code:
function _set_cookie($expire)
    {
        $CI =& get_instance();
        $CI->load->helper('cookie');

        $expire = (60 * $expire) + time();

        $cookie_name = $CI->config->item('sess_cookie_name');
        $cookie_data = get_cookie($cookie_name, TRUE);

        delete_cookie($cookie_name);

        setcookie(
                $cookie_name,
                $cookie_data,
                time() - 31500000,
                $CI->config->item('cookie_path'),
                $CI->config->item('cookie_domain'),
                0
                );

        setcookie(
                $cookie_name,
                $cookie_data, // session id
                $expire,
                $CI->config->item('cookie_path'),
                $CI->config->item('cookie_domain'),
                0
                );
    }

Thanks again!
#5

[eluser]WanWizard[/eluser]
You can modify the session expiration variable at runtime:
Code:
$this->session->sess_expiration = 60*30; // set it to 30 minutes




Theme © iAndrew 2016 - Forum software by © MyBB