Я пытаюсь преобразовать этот PHP в psp (страницы сервера python).Я в растерянности с функцией php exec и isset для переменных сеанса.
session_start();
if(isset($_POST["var"])){
//set session username
$username = (string)$_POST["var"];
$username = trim($username);
$_SESSION['username'] = $username; //store $username
}
if(isset($_SESSION['username'])){
$username = $_SESSION['username']; //store session[username] as $username
$cmd = '/var/www/cgi-bin/resolveID.py ' . escapeshellcmd($username);
$fullname = exec($cmd);
$_SESSION['fullname'] = $fullname;
}
else{
echo 'Your session has expired, please click <a href="https://devh.test.com/">here</a>';
exit;
}
Это то, что у меня есть
<%
import cgitb, session
cgitb.enable()
user_session = Session.Session()
#post info
if form.getvalue('var'):
varUsername = form.getvalue('var')
user_session['username'] = varUsername
#session set stuff
try:
if user_session['username']:
#is set
varUsername = user_session['username']
varCMD = '/var/www/cgi-bin/resolveID.py ' + varUsername
varFullname = subprocess.check_output(varCMD)
user_session['fullname'] = varFullname
except:
#not set
req.write('Your session has expired, please click <a href="https://dev.test.com/">here</a>')
%>