PHP Session Data Not Being Stored -
I am creating a login system, but when a user logs in, then it actually stores any data I do not want to do it in session. I also checked the session file, and it was empty. I have session_start (); On all the pages what I was doing wrong is the code for two main pages.
Login Code:
& lt;? If ($ DEBUG == true) {error_reporting (E_ALL); } "Header.php" is required; Need_once "dbinterface.php"; Need_once "user.class.php"; Need_once "config.inc.php"; $ Db = new db ($ db ['host'], $ db ['user'], $ db ['pass'], $ db ['database']); $ U_result = $ db- & gt; Play ("Choose user_id from user where user_name = '". $ Db-> escape ($ _ POST [' user_name ']). "'"); If ($ u_result == incorrect) {$ url = 'Location: error.php? Id = 8 '; Header ($ url); } If (count ($ u_result) & lt; 1) {$ url = 'Location: error.php? Id = 3 '; Header ($ url); } $ User = new user ($ u_result [0] ['user_id']); If ($ user- & gt; match_password ($ _ POST ['pass']) == true) {$ _SESSION ['authenticated'] = true; $ _SESSION ['user_id'] = $ u_result [0] ['user_id']; $ _SESSION ['user'] = $ user; } And {$ url = 'location: error.php? Id = 4 '; Header ($ url); } Session_write_close (); Header ('location: index.php'); ? & Gt;
Title included in each page:
A small background:
- Windows 7 (also tried on Windows
- Server 2008, but currently 7) PHP
- A 5 locally hosted problem exists
- Everyone exists for all issues
- Browser
Here are some suggestions (I do not really know what's going on and / or why, so they only suggest ; Maybe a problem will solve ^ ^)
First of all, some questions:
(if they do not do any of these suggestions at least)
- Which version of PHP / Apache are you using?
- Are you on Windows? Linux?
- If you are on your "Production" server, what is the hosting service? Maybe something special about it?
- Is there a problem for every one ?
- Is there always a problem when you are browsing the site?
- Is it still present when you are accessing the site from another browser?
- Computer?
- If you use something like
var_dump ($ _ session); Die;
What does the session set in the session at the end of the script, what does it give?
First thought: If you set some headers to disable caching by the browser?
Content like this, for example:
session_start (); Header ("Cache-Control: Private");
The second idea (at least if you are on windows): Did you try to deactivate the antivirus / firewall? Is the session cookie created correctly in the client's browser?
If you are using subdomain (or not): Is the cookie domain right? What's the end date about this?
Third opinion:
- You have said that
error_reporting
is set toE_ALL
, which is good - What about
display_errors
? Is it set up so that errors can be displayed? - Is something interesting in PHP / Apache's
error_log
?
Another one: Are you sure that there is nothing in output before session_start
? Not even white places?
Yet another: Are you sure about permissions on directory / files?
- Permission to write in a directory means that you can create new files, and / or delete old
- But, if I miss it correctly You can not modify them
- To modify the files, you should also have the facility of writing on files
- Actually, your webserver should Access to files is required. ^^
What is the permission on the directory of the session and on the (empty) files?
I am starting to run away from ideas ... with some luck, maybe one of them would be right ... or help you figure out what will be right!
Good luck!
Comments
Post a Comment