简体   繁体   中英

Session not working on Chrome and Firefox

I'm on a local machine (127.0.0.1) On login.php I create a session variable extracting value from DB

$_SESSION['user_id'] = $row['user_id'];

On upload.php I call variable

session_start();
$a = $_SESSION['user_id'];

And use variable on WHERE in a query:

$result = mysql_query("SELECT * FROM users WHERE user_id='" . $_SESSION['user_id'] . "'");
$result = mysql_query("SELECT * FROM users WHERE user_id='" . $_SESSION['user_id'] . "'");

Problem is, both query working well on Internet Explorer but NOT Working on Chrome and Firefox.

Any advice to solve this?

you should always include session_start(); in the head of every page that uses $_SESSION - unless it will not work properly - so in login.php also put it in the head

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM