Reputation: 705
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....
Upvotes: 3
Views: 121
Reputation: 455132
Since COOKIE_PREFIX
is a constant defined to have some value you should not be enclosing it in quotes. Instead try:
if (preg_match('#'.COOKIE_PREFIX.'#i', $key))
this would fail if COOKIE_PREFIX
contained a #
in it, so better use:
if (preg_match('#'.preg_quote(COOKIE_PREFIX,'#').'#i', $key))
Upvotes: 4