Empty variable $_SESSION



  • There's a page with a logic form that sends data from AJAX:

    function call() {
        if($(".nick").val() == "" || $(".pass").val() == "" || $(".capcha").val() == "") return false;
      var msg   = $('#loginform').serialize();
        $.ajax({
          type: 'POST',
          url: '/templates/logincheck.php',
          data: msg,
          success: function(data) {
            if(data == 'ok') window.location.href = "/ucp.php";
            else alert(data);
          },
          error:  function(xhr, str){
        sweetAlert("Ой", 'Возникла ошибка: ' + xhr.responseCode, "error");
          }
        });
    }
    

    Here. Send them to her. logincheck.php:

    <?php
    session_start();
    if(isset($_POST['login']))
    {
        if(isset($_POST['password']))
        {
            if(isset($_POST['capcha']) && $_POST['capcha'] == $_SESSION['captcha'])
            {
                require_once("connect.php");
    
            if ($stmt = $mysqli-&gt;prepare("SELECT `password` FROM `accounts` WHERE `player_name` = ?")) 
            { 
                $stmt-&gt;bind_param("s", $nickname); 
                $nickname = $_POST['login']; 
    
                $stmt-&gt;execute(); 
    
                $stmt-&gt;bind_result($password); 
    
                while ($stmt-&gt;fetch()) 
                {
                    $pswd = $password;
                }
    
                $stmt-&gt;close(); 
            }
            else echo 'err5';
    
            $mysqli-&gt;close();
    
            if($pswd == $_POST['password'])
            {
                $_SESSION['login'] = $nickname;
                echo 'ok';
            }
            else echo 'err4';
        }
        else echo 'err3';
    }
    else echo 'err2';
    

    }
    else echo 'err1';

    Recognizable data are in place. ucp.phpbut variable $_SESSION['login'] empty. What's the matter?

    ucp.php:

    <?php

    function createRedirect($where) {
    $s='<html><head>';
    $s.='<meta http-equiv="refresh" content="5; url='.$where.'">';
    $s.='</head><body>Ошибка. Вы будете перенаправлены <a href="'.$where.'">сюда</a>';
    $s.= '</body></html>';
    return $s;
    }

    if(!isset($_SESSION['login'])) die(createRedirect("login.php"));

    Read.

    P.S. In logincheck'e session remains, 100%. Debag doesn't show anything.



  • You've got a browser walking forbid keeping the cubes from your website. Go into the browser's building and do as it says:

    введите сюда описание изображения




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2