[eluser]boltsabre[/eluser]
You're passing 2 separate values to your function, but they are completely unique from each other. Why not combine into an array just pass one variable?
Perhaps you could do it like this:
Code:
//CODE UNTESTED, MAY BE BUGGY, BUT THIS IS THE JIST OF IT
//Just guessing that this stuff is happening in your controller, but put it wherever it really is
$user_pass = array ('user' => $user_whatever_it_is, 'pass' => $pass_whatever_it_is);
set_cookie($user_pass);
...
function set_cookie($input){
if(is_array($input)){
foreach ($input as $key => $value){
$cookie = array(
'name' => $key,
'value' => $value,
'expire' => $this->cookie_life,
'domain' => $this->cookie_dname,
'path' => '/',
'prefix' => '',
'secure' => FALSE
);
$this->input->set_cookie($cookie); //save info to cookie
}
}
}
This technically, is keeping your code DRY, but...
Depending on what you want to do, this may not be the best set up. If you are setting up lots of cookies, then you may need create a more complex function (which could be isolated into it's own helper file).
For example, what if one cookie needs a different path, or something else. Then you may want to pass a multi dimensional array instead of an associate array, etc.