1
I’m creating a redirect, coming from a link of email, for the user to access such link, URL.
However, the problem is that I am not being able to set the session to this URL!
Can someone help me?
Follow the code as it is:
logon.php:
if (isset($_POST["login"])){
$email = $_POST["email"];
$password = $_POST["password"];
$tabela_usuarios = "SELECT * FROM owner WHERE owner_email='$email' AND password='$password' ";
$resul = mysql_query($tabela_usuarios);
$regs = mysql_num_rows($resul);
if ($regs <> 0){
$owner_id = mysql_result($resul, 0, "owner_id");
$userName = mysql_result($resul, 0, "owner_firstName");
session_start();
$_SESSION['owner_id'] = $owner_id;
$_SESSION['owner_firstName'] = $userName;
if(isset($_SESSION['redirectURL'])) {
$url = $_SESSION['redirectURL'];
unset($_SESSION['redirectURL']);
header("Location: ".$url);
} else {
header("Location: default.php");
}
}else{
header("Location: ../index.html");
}
}
Login validation code:
include_once("con/conexao.php");
session_start();
$owner_id = $_SESSION['owner_id'];
$userName = $_SESSION['owner_firstName'];
if($userName == ""){
$_SESSION['redirectURL'] = "TESTANDO!!!";
var_dump($_SESSION);
//header("Location: ../index.php");
}
Shows some error?
– Sr. André Baill
No @Andrébaill. Dou um var_dump e ela não aparece... Somente as outras duas owner_id e iserName.
– GustavoSevero
Try inserting session_start at the beginning of the file.
– Sr. André Baill
But it’s at the beginning of the archive, @André Baill... Or I didn’t understand you.
– GustavoSevero
Remove
session_start();
from the middle of your code and put in the first line of execution, just after opening the php tag:<?php session_start();
– KaduAmaral
That’s what I said @Kaduamaral :) It’s the same situation. put session_start() at the beginning of the file, because in between it never works.. At least with me, it never worked!
– Sr. André Baill
I changed and keeps appearing NULL, in var_dump.
– GustavoSevero
@Andrébaill, I took session_start from where I was and moved to the first line. .
– GustavoSevero
@Kaduamaral, you have another suggestion?
– GustavoSevero
Any errors displayed? Enable errors
ini_set('display_errors',1); ini_set('display_startup_errors',1); error_reporting(-1);
to make sure that...– KaduAmaral