Oups... I think I found where my problem is.
The snippet was calling the following function :
function GetCartId()
{
// This function will generate an encrypted string and
// will set it as a cookie using set_cookie. This will
// also be used as the cookieId field in the cart table
if(isset($_COOKIE["id"]))
{
return $_COOKIE["id"];
}
else
{
// There is no cookie set. We will set the cookie
// and return the value of the users session ID
error_reporting(0);
session_start();
setcookie("id", session_id(), time() + ((3600 * 24) * 30));
return session_id();
}
}
After calling this piece of code, everything gets corrupted and I am no more able to access the manager or user interfaces. I get a lot of SQL errors. In manager, I cannot retrieve documents or open snippets, chunks, templates...
Might come from the session_start() ?
My snippet code is as follows :
if (empty($_GET["action"]))
{}
else
{
$action = $_GET["action"];
$item_id = $_GET["item_id"];
switch($action)
{
case "add_item":
{
$mydb= new DBAPI();
$mydb->connect('localhost','db', 'user','pwd');
$cookie = GetCartId();
$table = 'cart';
$where = 'cookie="'.$cookie.'"';
$rs = $mydb->select("*", $table, $where, '', '');
if ($mydb->getRecordCount($rs) > 10)
{$msg ="The shopping cart is full. You cannot add more than 10 items";}
else
{...
$msg = "The item has ben added to your cart";
...}
$mydb->disconnect();
$modx->setPlaceholder('msg', $msg);
}
}
}