I created my site on xp32 windows and a few days ago. Then set the same type of windows (professional xp 32 bit).
Now my site is not working properly. $_SESSIONS not sent, and I wonder if the windows have something with this (because I disabled some startup services in msconfig->services ). Another thing I suspect is XAMPP . After I found out the problem, I edited php.ini in Apache 1000times and this did not fix the problem. At Google, many people complain about a common problem. They say they changed the server and now the sessions are not sent.
I am new to php and don't know what exactly is going on.
Can someone help me with some tips on where the problem might occur, and also I would like to know if using session alternatives is good practice, for example, if the user logged_in()->send data to mysql-> SET logged_in = 1; and if l ogout() -> SET logged_in = 0 . Or something else. Any information on this would be helpful. Thanks!
here is the exact situation with the code: Project link: http://dox.bg/files/dw?a=e2f056d0f2 I have this login form:
<form action="login.php" method="post"> <ul> <li> <input type="text" name="username"> </li> <li> <input type="password" name="password"> </li> <li> <input type="submit" value="login"> </li> <li> <a href="register.php">register</a> </li> </ul> </form>
in login.php I have this:
... else { $_SESSION['user_id'] = $login; //... $_SESSION['user_id'] works here and outputs the correct data - user_id header('Location: index.php'); exit(); ...
and in int.php (it is included in index.php ), I have this:
session_start(); print_r(session_get_cookie_params()); echo '<br>'; // outputs: Array ( [lifetime] => 0 [path] => / [domain] => [secure] => [httponly] => ) print_r(session_status()); echo '<br>'; // output: 2 var_dump($_SESSION); // output: array(0) { } print_r($_SESSION); print_r($_SESSION['user_id']); // outputs: "Notice: Undefined index: user_id in C:\xampp\htdocs\orderfood\Core\int.php on line 10" require 'database/connect.php'; require 'functions/general.php'; require 'functions/users.php'; require 'functions/options.php'; if(logged_in() === true)//this is ok. { $session_user_id = $_SESSION['user_id']; // <-------- not working...
... the script continues
Fixed. I canβt explain exactly what happened, but I deleted session_start() from core/int.php (by the way, the path was written without "core /"), and I added session_start() in my index.php and in the files that require login.
This solved the problem for me. In fact, this seems to be a noobish bug. I had a site working in previous windows, but I accidentally deleted it, and the files that I submitted in ink were from an old backup, which I thought worked, but that was not true .. Sorry for the noob message and Thank you for your attention.