Skip to content

Commit

Permalink
Added the delete_cookie() function in order to help with the removal …
Browse files Browse the repository at this point in the history
…of cookies that might have been set. Although one can make use of the set_cookie() function and pass an 0 via the expire field, this is a simpler method
  • Loading branch information
jc1arke committed Mar 4, 2012
1 parent 3722e50 commit 386c3ec
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions system/core/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,27 @@ public function cookie($index = '', $xss_clean = FALSE)

// ------------------------------------------------------------------------

/**
* Remove cookie
*
* Accepts the name of the cookie and expires it accordingly
*
* @param string the name of the cookie
* @return bool
*/
public function delete_cookie($name = '')
{
if( isset($name) && !empty($name) && $this -> cookie( $name ) ) // Check if the cookie exists, just a failsafe, one never knows.... :)
{
$this -> set_cookie( $name, '', 0 );
return true; // Let the calling function know that it succeeded
}

return false; // Could not find the cookie, or no name provided
}

// ------------------------------------------------------------------------

/**
* Set cookie
*
Expand Down

0 comments on commit 386c3ec

Please sign in to comment.