Resetting the cookies to default after messing them up. |
Description: A quick guide on how to reset the cookie settings back to default, even if you can't login. |
Author: NeoThermic |
Date: Wed Feb 18, 2004 12:28 pm |
Type: HowTo |
Keywords: cookies, resetting, cookie_secure, cookie_domain, cookie_path, cookie_name |
Category: Miscellanea |
 |
Resetting the cookies to default after messing them up.
Scenario
You have finally got your phpbb board running perfectly. You now decide it’s a good time to try and edit the cookie values so that they are more unique. You change a few cookie settings, click apply... and then are logged out. To your utter horror, you realise that you've broken the cookies, and no one, not even the admin can log back in and fix it.
What’s worse is that you don't have SSH access to the database / phpmyadmin access to the database. Or that you are on limited time to get this problem solved. Your users are depending on you to fix this problem, and fast.
Solution
Thankfully, as long as you still can upload files to your site, you are in luck. Just put this code below in your phpbb root and then navigate to it in your browser.
Code: |
<?
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
//reset cookie name
echo "Resetting: Cookie_Name<br>";
$sql = "update `" .$table_prefix."config` set `config_value`='phpbb2mysql' where `config_name`='cookie_name'";
echo "Query: <br>";
echo $sql;
echo "<br>";
$result = $db->sql_query($sql);
if ($result == 1) {
echo "<b><font color='green'>Sucess!</font></b><br>";
} else {
echo "<b><font color='red'>Failure!<br></font></b>";
}
echo "<br><br>";
//reset cookie path
echo "Resetting: Cookie_Path<br>";
$sql = "update `" .$table_prefix."config` set `config_value`='/' where `config_name`='cookie_path'";
echo "Query: <br>";
echo $sql;
echo "<br>";
$result = $db->sql_query($sql);
if ($result == 1) {
echo "<b><font color='green'>Success!</font></b><br>";
} else {
echo "<b><font color='red'>Failure!<br></font></b>";
}
echo "<br><br>";
//reset cookie domain
echo "Resetting: Cookie_Domain<br>";
$sql = "update `" .$table_prefix."config` set `config_value`='' where `config_name`='cookie_domain'";
echo "Query: <br>";
echo $sql;
echo "<br>";
$result = $db->sql_query($sql);
if ($result == 1) {
echo "<b><font color='green'>Success!</font></b><br>";
} else {
echo "<b><font color='red'>Failure!<br></font></b>";
}
echo "<br><br>";
//reset cookie secure
echo "Resetting: Cookie_Secure<br>";
$sql = "update `" .$table_prefix."config` set `config_value`='0' where `config_name`='cookie_secure'";
echo "Query: <br>";
echo $sql;
echo "<br>";
$result = $db->sql_query($sql);
if ($result == 1) {
echo "<b><font color='green'>Success!</font></b><br>";
} else {
echo "<b><font color='red'>Failure!<br></font></b>";
}
?>
|
The above code is DBAL compliant, and should work for all database types, although I've currently only tested it on MySQL databases.
Once run, you should see it do some SQL queries, but the most important part is the Success! bits. You should see four of them, no red text. If you see any red text, then you have more problems than this article can go into.
More resources
The whole topic that started this small bit of code was this one, and would be a good place to look. And spot the spelling mistake
Other articles and help can be found in the Knowledge Base and in the ever helpful User Guide.
For more help on how/what to set the cookies to on your forums, then this section of the User Guide is what you are looking for.
End of article
NeoThermic |
|
|