Forum Moderators: coopster

Message Too Old, No Replies

https to http session variable problems

ssl http https pass variables

         

Bhavin_Shah

12:54 pm on May 9, 2009 (gmt 0)

10+ Year Member



Hello,

i m junior programmer... and i m really in a mess with this https to http stuff...

====>My Problem:
1. Not able get any global variables from https to http.. as those are considered as different domains....

2. when my user logs in i want some of it info in http but my sessions are created in https so i m not able to access it.

====>What i have tried
1. I have tried to get all the $GLOBALS variable over https to http but failed every time....

2. i have tried to pass hidden variables from https to http...but the problem is i have to put them into form which should be posted all the time ...

====> My Questions..

1.. Is this the right way what i am doing ?
2. If Yes.... how can i make a form should submit my data everytime without any event (accept javascript or with javascript)... i have not tried by adding javascript coz what if script in browser so i need to do it without it...!?

3..if u can suggest me other option which is better than this than i am ready to listen.?

Thanks for reading my post .. if u have solutions please provide me....

Thanks,
Bhavin Shah

coopster

6:12 pm on May 9, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, Bhavin_Shah.

If you need to pass the data from secure to non-secure mode you should be able to set the session cookie to bridge between the two. The PHP manual page for session handling is a must read for anybody using sessions and be sure to read and understand what each session configuration directive [php.net] does.

Bhavin_Shah

7:09 am on May 11, 2009 (gmt 0)

10+ Year Member



okey thanks for the reply i have read the link which u gave ... i made the settings runtime.. but i guess it is taking settings from php.ini from it.. but in my local if i make changes in that than it creates problem(some conflicts) in my other local sites...

what i have done

session_set_cookie_params(0,"secure.mydomain.com/file.txt",".mydomain.com");

i have written this line when i have verified log in and created session registered variables.... i have put this line before session_start()

and when i have called session_get_cookie_params() it gave me all the default variable which are specified in php.ini...

well what i think for my solution ====>>

i should ask my hosting company to set this in my domain php.ini

session_set_cookie_params(0,"secure.mydomain.com/file.txt",".mydomain.com");

httpdocs and httpsdocs are at same level....

so i have to give static path to access session params....

and when ever i need to access sesssion which are created in secure site i ll call session_get_cookie_params(); before i start the session or i use any $_Session['VariableName']

this is what i understood from the the link u provided not much example to do it .....

please tell me should i continue with my thought or i am missing something?

Thanks,
Bhavin Shah

Bhavin_Shah

7:22 am on May 11, 2009 (gmt 0)

10+ Year Member



Continued........

the reason i have put ".mydomain.com" i am guessing that as httpdocs & httpsdocs are same level

httpdocs is accessible : www.mydoamin.com
httpsdocs is accessible: secure.mydomain.com

and i want to access secure.mydomain.com session in www.mydoamin.com

so am i able to do it with this string?

session_set_cookie_params(0,"secure.mydomain.com/file.txt",".mydomain.com");

?

coopster

1:25 pm on May 11, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Did you test it? Read more about cookie domain information here: setcookie [php.net].

enigma1

1:21 pm on May 12, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You are using 2 different domains so under normal circumstances (ie without intermediate redirects) you cannot send another cookie before the transition (http -> https and vice versa). However you can pass the session identifier via the URL.

eg:
http://www.example.com/index.php?sid=123 => [secure.example.com...]

Then you examine the /GET array to retrieve the id. You compare/validate it against the sessions stored and you issue the 2nd cookie if everything is good.