Cookies not working apache - nginx

I have moved my site from apache to nginx, but now I have a problem with my site not wanting to send cookies (or start a session) to my users when they try to login to the website.

This is my log script:

<?php
session_start();
include("includes/config.php");
$naam = mysql_real_escape_string($_POST["naam"]);
$wachtwoord = md5(mysql_real_escape_string($_POST["wachtwoord"]));

if (strlen($naam) > 0)
{
if (strlen($wachtwoord) > 0)
{
    $uQuery = mysql_query("SELECT * FROM users WHERE username = '".$naam."' AND password = '".$wachtwoord."' LIMIT 1");
    if (mysql_num_rows($uQuery))
    {
        while($lid = mysql_fetch_array($uQuery)) {
            $id = $lid["id"];
        }
        $_SESSION["lid"] = $id;
        header("Location: me.php");
    } else {
        header("Location: index.php?error=1");
        }
    }
}
?>

      

This is what I use to connect to MySQL (My config file):

<?php

$host = "ip address";
$username = "root";
$password = "password";
$db = "test";

 $con = mysql_connect($host, $username, $password);
if (!$con){ die('Verbinding mislukt: ' . mysql_error()); }
$db = mysql_select_db($db, $con);
if (!$db){ die ('Kan database niet vinden: ' . mysql_error()); } 
?>

      

Does anyone know how to fix it?

Here's my nginx config:

#
# The default server
#
server {
listen       80 default_server;
server_name  ;

#charset koi8-r;

#access_log  logs/host.access.log  main;

# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;

location / {
    root   /usr/share/nginx/html/shine;
    index index.php   index.html index.htm;
}

error_page  404              /404.html;
location = /404.html {
    root   /usr/share/nginx/html;
}

error_page  404              /404.html;
location = /404.html {
    root   /usr/share/nginx/html;
}

# redirect server error pages to the static page /50x.html
#
error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   /usr/share/nginx/html;
}

# proxy the PHP s to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
#    proxy_pass   http://127.0.0.1;
#}

# pass the PHP s to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {

    root           /usr/share/nginx/html/shine;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params;
}

# deny access to .htaccess files, if Apache document root
# concurs with nginx one
#
#location ~ /\.ht {
#    deny  all;
#}
}

      

Thank!

+3


source to share


1 answer


Thanks for the help. I found a fix for this. The cookie save folder was not there and did not have the correct cmod.

This team solved it:



mkdir / var / lib / php / session chmod -R 777 / var / lib / php / session

0


source







All Articles