Quick $_SESSIONS question

Hi,
I have a quick sessions question, if I set a session on page1.php then go to some other site and come to page2.php

will the session still be there??

The reason I ask is this:
I want to set a session in "register_step_2.php" called "client_id" then the client goes to 2checkout .com fills in the payment details etc and gets directed to "register_step_3.php" where i want to read the session values again...

Thanks,
Mag
LVL 2
mag1c1anAsked:
Who is Participating?
 
minichickenCommented:
Hi Mag

Session across domains causes issues, normally the session will not be recognize when you go to 2Checkout and then back to your site. You will need a word around for it.

Have a look the replies at http:Q_21155588.html about SESSION ACROSS DOMAINS on 2CHECKOUT

regards-

0
 
Diablo84Commented:
yes

Session data will be available as long as the browser window is open, so if they go to your site, navigate away and then come back again the data will still be available. The data will only be lost if they close their browser.
0
 
mag1c1anAuthor Commented:
Hi Diablo,
Thanks for replying.

I have been reading about sessions in the manual and it says that the session is stored on the users disk as a cookie, so if cookies are turned off I suppose that it gets written to the URL string as PHPSESSID...if thats the case, I cannot pass that sessid to 2checkout so how do i get back the session?

Am i missing something or is there another way?

Thanks,
Mag
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
mag1c1anAuthor Commented:
Hi MiniChicken,
I guess I have no choice...will store the session variable in a table and send the client_id of the table to 2co, then on the other side query the db for those varables etc....

Thanks,
Mag
0
 
minichickenCommented:
Hi Mag

I suppose so, need to do a work around.... well, at least that how I got it to work... :)
0
 
Ivanov_GCommented:
> the session is stored on the users disk as a cookie.

Not exactly... There are just cookies and "session cookies". Cookies output a file on your HDD, while session cookies don't. For session cookies there are files server-side. If you see in your PHP.ini file, you can find something like session.save_path = C:\WINNT\TEMP\. When you call session_start() go in this folder and see how a new file has been created. But this is on the SERVER, not on client machine.

In IE, Tools / Options / Privacy / Advanced. There you see the settings for the session cookies.

> will store the session variable in a table and send the client_id

Implementing just DB-aware session will take you a lot of time. In Perl you have packages which use DB to store sessions, but in PHP ... I haven't heard. So you can find statistic about how many people have disabled session cookies. BTW recently I red some stats from WebCounter website. The result was less than 0,5%.
0
 
mag1c1anAuthor Commented:
Hi,
Thanks for replying.

I didnt know about those server side cookies...learning something everyday :-)

Anyway, 2checkout REALLY sucks, the variable gets passed sometimes and sometimes...its just blank, I have check (manually) and its not my programs fault...so now am trying to do it with just client side cookies, if cookies are not being set, output an error message and ask the client to put cookies on...

:-(

Mag
0
 
BenMorelCommented:
For each session, the navigator has to remember your session ID.
If the IE "security" level is high, it won't.

To avoid this, redirect the user after payment to this url :
$url = 'register_step_3.php?' . SID; // SID is a constant, let it outside the string

Note: SID will *always* be declared as soon as the session is started.
it's an empty string is your server has detected a session cookie, it's the url variable otherwise (i.e. PHPSESSID=xxxxxxx)

Regards,
Ben
0
 
Ivanov_GCommented:
You can use GET parameters. On the first page register_step_1.php you generate somehow the session ID - you can use IP, date and make a MD5 for this string. So the link for step 2 will be register_step_2.php?sid=2iut5ilkjehjgsdgjdshgks and on next page you will :
$sid = $_GET['sid'];
Then pass it to step_3, and so on.

Thus the session will be independent from cookies.
0
 
eeBlueShadowCommented:
Ivanov_G,

The problem is that the user is redirected to a third party site, rather than staying within the site. So, the session ID can't be passed as there is a 'break in the chain' from page to page.
0
 
mag1c1anAuthor Commented:
Hi Guys,
Since I am using the recurring part of 2co, I finally settled on this solution:

I am just takeing the values of the 4 variables in the session (for the sake of this example var1,var2,var3, var4) and passing it on to the merchant_order_id...

eg:
merchant_order_id=$var1."_".$var2."_".$var3."_".$var4

and in the final page I am doing an explode on the underscore and takeing the variables out again


Not the best of solutions...but its working :-)

I hope this helps someone else in future.

Cheers,
MAg
0
 
mag1c1anAuthor Commented:
Since I didnt really get the answer from any one...am increasing the points and splitting it...

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.