I have a problem with xampp when I want to start a session. I have created a user in a MySQL database. My signing form refers to this php script:
<?php
session_start();
?>
//...
<?php
$User = $_POST["User"];
$Pswd = $_POST["Pswd"];
//reference to current script $_SERVER['PHP_SELF'];
$con = open1($User, $Pswd);
if(isset($User)) {
if (!empty($_POST['User']) && !empty($_POST['Pswd'])) {
$username = mysqli_real_escape_string($con, $_POST['User']); // get rid of special characters in 'User'
$password = md5(mysqli_real_escape_string($con, $_POST['Pswd'])); // calculated md5 hash of the password string
$checklogin = mysqli_query($con, "SELECT * FROM registrovany_uzivatel WHERE Uziv_jm = '" . $User . "' AND Heslo = '" . $Pswd . "'");
if (mysqli_num_rows($checklogin) == 1) {
//session_start();
$row = mysqli_fetch_array($checklogin);
$username = $row['User'];
$email = $row['Email'];
$name = $row['Name'];
$surname = $row['Surname'];
$_SESSION['Username'] = $username;
$_SESSION['Email'] = $email;
$_SESSION['Name'] = $name;
$_SESSION['Surname'] = $surname;
//session_id($_GET['PHPSESSID']);
if (!isset($_SESSION['errors']))
header('location: search_course.php');
exit(); // Output a message and terminate the current script
}
}
}
Warning: session_start(): The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in C:\xampp\htdocs\swscholar\search_course.php on line 4
So I have renamed the start_session()
function to my_start_session()
which eliminates chars in the session id (I found one somewhere in there on StackOverflow) but I got an error in the search_course
script that there isn't any existing $_SESSION
set.