I have a query that returns me the hits of the user who just logged in. I need to turn them into an array and store them in a session and a cookie. Here is the code:
//ARMAZENA AS PERMISSOES DO PERFIL DO USUARIO
if($sql_permissoes->rowCount() > 0){
$permissao_visualizacao = array();
$permissao_alteracao = array();
foreach ($sql_permissoes as $sql_permissoes_row) {
$permissao_visualizacao[] = $sql_permissoes_row["url_localizacao"];
$permissao_alteracao[] = $sql_permissoes_row["permite_alteracao"];
}
}
$_SESSION["ged.permissao.visualizacao"] = $permissao_visualizacao;
$_SESSION["ged.permissao.alteracao"] = $permissao_alteracao;
setcookie("ged.permissao.visualizacao", $permissao_visualizacao, mktime(0, 0, 0, date("m"), date("d")+5, date("Y")) );
setcookie("ged.permissao.alteracao", $permissao_alteracao, mktime(0, 0, 0, date("m"), date("d")+5, date("Y")) );
But in the setcookie lines I get the following message:
Warning: setcookie() expects parameter 2 to be string, array given.
What is the most recommended method of doing this?