hey guys, i'm having a little problem. I'm working on a wordpress template which lists all files on my ftp. Therefore i ask for the the password and pass it straight along to the ftp_connect.
So the structure looks like this. I'm asking for the password, and if entered (and send) i'll include a file called ftp_include.php which lists all my files. That's working fine so far.
The only problem I have is that I reload/refresh this inlcude with Ajax (jQuery). However only the include. And everyime i refresh this include has to connect to the server again (with the password entered at the beginning).
A few guys already told me here that I need to work with SESSIONS in PHP, which store my password and inside my include i'm retrieving it again.
Somehow i can't figure out why my SESSION cookie wont work. I guess it's getting stored properly with this:
session_start();
session_start();
if(!isset($_SESSION['ftp-password']) ) {
$_SESSION['ftp-password'] = $_POST['password'];
}
var_dump(ini_get_all('session')); //shows both times
//this result:http://cl.ly/1hzA ->
//so it seems it doesn't get stored properly, does it?
i think so because i'm retrieving the password inside the include with this lines:
if(isset($_SESSION['ftp-password']) ) {
$ftp_user_pass = $_SESSION['ftp-password'];
echo "Password: " . $ftp_user_pass;
} else {
print "can't find cookie!";
}
and it even CONNECTS to the server for the first time. However as soon as i refresh the include with Ajax somehoe it always says "can't find cookie". Any idea why that happens. I even tried with set_cookie() but the same result.
thank you for your tips