I’ve upgraded my php to 5.3 so i need to change regex expressions to preg_match. I’ve successfully made few changes to a script using delimiters and changing regex to preg_match but i’m struck with the following code which i tried to change in the following way though i didn’t get any error cookies are not getting deleted.
if (preg_match('#COOKIE_PREFIX#i', $key))
Original code is
// destroys the session cookies
function destroy($hash)
{
foreach ($_COOKIE as $key => $value)
{
if (eregi(COOKIE_PREFIX, $key))
{
$key = str_replace(COOKIE_PREFIX, '', $key);
xtsetcookie($key, '');
}
}
$this->userinfo['user_id'] = 0;
}
P.S: The script developer is not replying to my support requests….
Since
COOKIE_PREFIXis a constant defined to have some value you should not be enclosing it in quotes. Instead try:this would fail if
COOKIE_PREFIXcontained a#in it, so better use: