How to send COOKIE, PHPSESSID from my own webserver to php5-cgi script

Asked by Melvin Josecom

 I am developing a Webserver in C. I know how to pass environment variables to ph5-cgi, eg:

putenv("QUERY_STRING=");
 putenv("REQUEST_METHOD=GET");
 putenv("REDIRECT_STATUS=true");
 putenv("SERVER_PROTOCOL=HTTP/1.1");
and start php5-cgi as child,

execl("/usr/bin/php5-cgi", "php5-cgi", NULL);
Actually this logic works for all PHP pages which dont have session_start() or which doesn't use SESSION["username"] = $username;, codes.

That is, I get COOKIE variable from browser,

Cookie: PHPSESSID=3cosh0uv4673gfru63gaobgbd6
Istored this PHPSESSID in C variable phpsessid. So now,

phpsessid=PHPSESSID=3cosh0uv4673gfru63gaobgbd6
The problem is I failed to pass the COOKIE from my webserver to php5-cgi script.

HOW CAN I PASS/FORWORD the COOKIE/PHPSESSID value to php5-cgi script to validate the user in php pages?

Any ENVIRONMENT variable do I need to set?

Or do i need to write into STDIN of the script?

here is the SESSION check in my php page,

if(!$_SESSION['valid_user']){
    header('Location:user_login.php');
}
Here I failed to check $_SESSION["valid_user"], because it is not known to the php page. It is there in my WEBSERVER. How can I pass SESSION to ph5-cgi-script?

The cgi script send back to my server an error:

 PHP Notice: Undefined index: valid_user in /home/WEBSERVER/user_auth_fns.php on line 63

Question information

Language:
English Edit question
Status:
Expired
For:
Ubuntu php5 Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.