0
I have a website and a forum, and I would like users to use the same login and password on both. and if possible I would also like you both to share the same session, so you don’t need to log in twice.
0
I have a website and a forum, and I would like users to use the same login and password on both. and if possible I would also like you both to share the same session, so you don’t need to log in twice.
0
Doing this using session is not possible, the session remains active only in the domain that created it, at most what could be done would be to share this session for use in the subdomains of the domain in question. To make them use the same Login and Password you can use cookies. An example of this use follows below:
ob_start(); // using this command will have no problems if the page contains html,
if($acao==logar){
include "config.php";
$usuario = $_POST["usuario"];
$senha = $_POST["senha"];
$sql = mysql_query("select * from tabela where usuario='$usuario' AND senha=MD5('$senha')"); /* verifico se o usuário e a senha estão corretos */
$sql2 = mysql_query("select `usuario`, `senha`, `nivel` from tabela where
usuario='$usuario' LIMIT 0,1", $conexao); /* verifico o nivel do usuário
logado */
$busca = mysql_num_rows($sql); /*verifico se ocorreu resultado*/
$array = mysql_fetch_array($sql2);/*se ocorreu crio um array para os dados
recebidos */
$usuario = $array["usuario"];
$senha = $array["senha"];
$nivel = $array["nivel"];
if(($busca > 0) && ($array > 0)){ /* crio os cookies */
setcookie("usuario", $usuario);
setcookie("senha", $senha);
setcookie("nivel", $nivel);
header("location: admin.php");
}
else{
echo"Erro ao se logar.";
}
}
I hope I helped! Hugs!
Browser other questions tagged php
You are not signed in. Login or sign up in order to post.
Post the code of what you’ve done or your difficulties in the process.
– Rafael Augusto
my main difficulty is to make the same session of the site serve for the forum. what happens is this, I have a server in java that connects with a database and the site takes the data of this database to login, already the forum has its own database, and Session does not send from one page to another because they both have different files to send to Session
– fnatic gamer
Very broad the question, Be more specific with the problem, supplement the question by clicking Edit. About the answer, look about SSO - Single Sign On.
– Alexandre Cavaloti