Hi, I'm doing this for the first time, so please forgive me if I ask something dumb...
First, here're php.ini settings related to handling sessions:
[Session]
session.save_handler = files
session.save_path = "C:\windows\tmp"
session.use_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 1800
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly = 0
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.bug_compat_42 = 0
session.bug_compat_warn = 1
session.referer_check =
session.entropy_length = 0
session.entropy_file =
session.cache_limiter =
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 5
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
This file, if passed login section (don't mind it, it's not the actual script I use to authenticate the user, just an example) Is supposed to redirect the browser to another page, where I would like to get session variables.
<?php
session_start();
session_regenerate_id(true);
function session_started(){
if(isset($_SESSION)){
return true;
}else{
return false;
}
}
function go_relogin(){
session_unset();
session_destroy();
header('Location: login.php');
}
if ($_POST["user_name"] == "admin"){
if ($_POST["user_password"] == "password") {
$user_admin = true;
$user_login = $_POST["user_name"];
$user_pwd = $_POST["user_password"];
$_SESSION["suser_admin"] = 1;
$_SESSION["suser_name"] = $user_login;
$_SESSION["suser_password"] = $user_pwd;
session_write_close();
if (!session_started()) {
exit ("Failed to start session!");
}
output_success();
} else {
go_relogin();
}
} else {
go_relogin();
}
if(!$user_admin) exit("wrong login / password!");
function output_success () {
if ($_SESSION["suser_admin"]) {
header('Location: manage_uploads.php');
//print "<a href=\"manage_uploads.php\">Manage uploads</a>";
} else {
print "There\'s something weird going on with the session...";
}
}
?>
And here's the manage_uploads.php
function session_started(){
if(isset($_SESSION)){
return true;
}else{
return false;
}
}
if(!session_started()) exit ("Session not started!"); // always exits here, no matter what...
What am I doing wrong?
TIA.