I'm working on an application that uses sessions to store user info. When the user logs in by entering a name and password, a login page authenticates the user and then sets a session variable to store the username. However, since I was redirecting to the main page via the header() function after authentication, I was using session_write_close() to make sure the variable would be available to the page I redirected to. This worked fine until recently when a co-worker changed the php.ini file. Now that variable throws an undefinied error. The variable that was set on the login page no longer makes it to the redirected main page. Here's the relevant code:
login.php
Code: Select all
// If theres a match send them to main.php
if ($pw == $row[0]) {
session_register("user");
$_SESSION['user'] = $user;
session_write_close();
header("Location: main.php");
}This all worked before the ini file was mucked with, so I'd really like some ideas on what is missing or whatever since I'm out of ideas. My only alternative is to rewrite the app to use cookies instead, which I really don't want to do since it was nearly ready for production in the first place.
Here's the Session info. I've also made sure the directory is writeable as well:
Session Support enabled
Registered save handlers files user
Directive Local Value Master Value
session.auto_start Off Off
session.bug_compat_42 On On
session.bug_compat_warn On On
session.cache_expire 180 180
session.cache_limiter nocache nocache
session.cookie_domain no value no value
session.cookie_lifetime 0 0
session.cookie_path /var/lib/php/session /var/lib/php/session
session.cookie_secure Off Off
session.entropy_file no value no value
session.entropy_length 0 0
session.gc_divisor 100 100
session.gc_maxlifetime 1440 1440
session.gc_probability 1 1
session.name PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler files files
session.save_path /tmp /tmp
session.serialize_handler php php
session.use_cookies On On
session.use_only_cookies Off Off
session.use_trans_sid Off Off