• 06-08-2022, 22:52:04
    #1
    🧙 Kod Sihirbazı 🧙
    <?php
    session_start();
    if(isset($_SESSION['screen_width']) AND isset($_SESSION['screen_height'])){
        echo 'User resolution: ' . $_SESSION['screen_width'] . 'x' . $_SESSION['screen_height'];
    } else if(isset($_REQUEST['width']) AND isset($_REQUEST['height'])) {
        $_SESSION['screen_width'] = $_REQUEST['width'];
        $_SESSION['screen_height'] = $_REQUEST['height'];
        header('Location: ' . $_SERVER['PHP_SELF']);
    } else {
        echo '<script type="text/javascript">window.location = "' . $_SERVER['PHP_SELF'] . '?width="+screen.width+"&height="+screen.height;</script>';
    }
    ?>
    Bu kod çalışıyor lakin istediğim şey php değerlerine aktarmak
    $width
    $height
    gibi değerlere
    else kısmındaki değerleri aktarmak istiyorum
  • 08-08-2022, 22:46:33
    #2
    Ben test.php sayfasında örnek olarak test ettim.
    Kendi sayfanıza göre ayarlarsınız. Ajax ilede olabilir alternatif olarak
    <?php
    session_start();
    
    if (isset($_SESSION['screen_width']) && isset($_SESSION['screen_height'])) {
        echo 'User resolution: ' . $_SESSION['screen_width'] . 'x' . $_SESSION['screen_height'];
    } else if ($_GET['screen_width'] && $_GET['screen_height']){
        $_SESSION['screen_width'] = $_GET['screen_width'];
        $_SESSION['screen_height'] = $_GET['screen_height'];
        header('Location: /test.php');
    } else {
        echo '<script> window.addEventListener("load", (event) => { window.location.href = "/test.php?screen_width=" + screen.width + "&screen_height=" + screen.height; }); </script>';
    }