Customizing SMF > SMF Coding Discussion

[WIP/BETA] EU cookie law

<< < (39/46) > >>

nend:
I was thinking of a easier solution, well here is my idea hope you like it.


--- Code: ---<?php
ob_start('callback');
setcookie('test', '123', time()+3600);
echo '123';
ob_end_flush();
function callback($buffer) {
header_remove('Set-Cookie');
return $buffer;
}
?>

--- End code ---

Just a simple test script which removes the cookie from the header before sending. Instead of invading all mods and locations in SMF where a cookie is set it might just be simpler just removing all the headers that were set. What do you think?

Arantor:
I think I already tried doing that before and finding that it didn't always work to remove the PHPSESSID cookie.

nend:
It looks like you have to call it the number of cookies that are set. So if two cookies are set I must call the function twice. Figured it would be recursive. Well updated with compatibility for older PHP.


--- Code: ---<?php
ob_start('callback');
setcookie('test', '123', time()+3600);
echo '123';
ob_end_flush();
function callback($buffer) {
if (function_exists('header_remove')) {
header_remove('Set-Cookie');
} else {
header('Set-Cookie:');
}
return $buffer;
}
?>
--- End code ---

Arantor:
Did you try using it to remove the PHPSESSID cookie, though?

That's the only cookie set until logging in and it doesn't behave the same way!

nend:

--- Quote from: Arantor on June 20, 2012, 01:49:00 PM ---Did you try using it to remove the PHPSESSID cookie, though?

That's the only cookie set until logging in and it doesn't behave the same way!

--- End quote ---
Just tried and both methods remove the PHPSESSID cookie, header and header_remove.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version