passing soap session_id to another php file

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

pavithrar
New php-forum User
New php-forum User
Posts: 7
Joined: Wed Jun 12, 2013 4:58 am

passing soap session_id to another php file

Postby pavithrar » Wed Jun 12, 2013 5:17 am

hi,
i want access the variable from one php file to another php file. because i am using soap. here is my code

$loginsession = new SoapClient("https://soappath/wsdlfile.wsdl");
//getting session_id to variable
$loginsessionresponse = $loginsession->__soapCall('login', array("login" => "myusername", "password" => "mypassword"));
//printing session id
echo '<pre>'.print_r($loginsessionresponse,true).'</pre>';


the above code is successfully running. and it will print session_id EX:45765786rtfgsdfdtgdfggdf
after this i am redirecting to another page using header();

header("Location: afterlogin.php");

my problem is how to pass this session_id to afterlogin.php file

please give any suggestions, thanks in advance

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: passing soap session_id to another php file

Postby johnj » Wed Jun 12, 2013 5:46 am

Try: header("Location: afterlogin.php?sessid=45765786rtfgsdfdtgdfggdf");

pavithrar
New php-forum User
New php-forum User
Posts: 7
Joined: Wed Jun 12, 2013 4:58 am

Re: passing soap session_id to another php file

Postby pavithrar » Wed Jun 12, 2013 10:15 pm

thanks johnj..

it is working fine. but the session id is visible on url to every one, i want to pass this session_id to other pages also. this not secure way. how to avoid this.

pavithrar
New php-forum User
New php-forum User
Posts: 7
Joined: Wed Jun 12, 2013 4:58 am

Re: passing soap session_id to another php file

Postby pavithrar » Thu Jun 13, 2013 4:17 am

i got solution for this problem. but not sure this is 100% correct. it is working for me

we can pass variable like
session start();
$_SESSION['session_id'] = $loginsessionresponse;

//in afterlogin.php
if (isset($_SESSION['session_id'])) {
$session_id = $_SESSION['session_id'];
echo $session_id; // it will print the same session id
}


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 3 guests

cron