Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Quick $_SESSIONS question

Posted on 2004-10-30
12
Medium Priority
?
226 Views
Last Modified: 2008-03-17
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
0
Comment
Question by:mag1c1an
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +3
12 Comments
 
LVL 27

Assisted Solution

by:Diablo84
Diablo84 earned 200 total points
ID: 12453388
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
 
LVL 2

Author Comment

by:mag1c1an
ID: 12453406
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
 
LVL 12

Accepted Solution

by:
minichicken earned 200 total points
ID: 12453636
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Author Comment

by:mag1c1an
ID: 12453799
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
 
LVL 12

Expert Comment

by:minichicken
ID: 12453918
Hi Mag

I suppose so, need to do a work around.... well, at least that how I got it to work... :)
0
 
LVL 12

Assisted Solution

by:Ivanov_G
Ivanov_G earned 200 total points
ID: 12454102
> 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
 
LVL 2

Author Comment

by:mag1c1an
ID: 12454135
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
 
LVL 7

Assisted Solution

by:BenMorel
BenMorel earned 200 total points
ID: 12454183
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
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 12455976
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
 
LVL 10

Assisted Solution

by:eeBlueShadow
eeBlueShadow earned 200 total points
ID: 12458344
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
 
LVL 2

Author Comment

by:mag1c1an
ID: 12458411
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
 
LVL 2

Author Comment

by:mag1c1an
ID: 12458419
Since I didnt really get the answer from any one...am increasing the points and splitting it...

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question