PHP会话被破坏了

My website was under a folder /test/ for example, and everything was working great. I was using relative urls and after I moved the site to the root folder, everything got double slashes.

For example: test.com// etc and I fixed it through htaccess url rewrite, but when I login, my site is getting redirected to the homepage where I can see the user menu which means the session exists. But when I click on settings and navigate to the settings edit page, I automatically get redirected to login page for the reason that there is no session exists.

Everything was working great before site move to root folder, so nothing wrong with coding I think, any ideas what it can be?

config.php

<?php
    $username = "***";
    $password = "***";
    $host = "***";
    $dbname = "***";

    $options = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8');

    try
    {
        $db = new PDO("mysql:host={$host};dbname={$dbname};charset=utf8", $username, $password, $options);
    }
    catch(PDOException $ex)
    {
        die("Failed to connect to the database: " . $ex->getMessage());
    }

    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);

    if(function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc())
    {
        function undo_magic_quotes_gpc(&$array)
        {
            foreach($array as &$value)
            {
                if(is_array($value))
                {
                    undo_magic_quotes_gpc($value);
                }
                else
                {
                    $value = stripslashes($value);
                }
            }
        }

        undo_magic_quotes_gpc($_POST);
        undo_magic_quotes_gpc($_GET);
        undo_magic_quotes_gpc($_COOKIE);
    }

    session_start();

Top of edit.php

require("config.php");
require('includes/top.php');
if(!isset($_SESSION['user']))
{
    header("Location: /login.php");
    die("Redirecting to login.php");
}

Thanks in advance.