Session Variable Life?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Session Variable Life?

Post by spacebiscuit »

Hi,

I am loading my php script's session variables with values before re-directing the user to a 3rd party payment processing page. When payment is complete the user is then directed back to my script where a success message is printed. I then want to access the session variable but they appear to be empty.

I thought that the session remianed live until the browser window is closed, is this not correct?

Thanks in advance,

Rob.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Session Variable Life?

Post by Jonah Bron »

When you redirect the user to the 3rd party payment site, do you send it a return URL? If you do, append...

'?' . urlencode(session_name()) . '=' . urlencode(session_id())

...to the end. That may help.
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Re: Session Variable Life?

Post by spacebiscuit »

Thanks for the reply.

Yes there is a return success URL which I specifiy, I will try as you suggested and report back my findings!

Rob.
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Re: Session Variable Life?

Post by spacebiscuit »

The return URL is psecified in an HTML as follows:

<input type="hidden" name ="responderurl" value="http://www.mydomain.com/index.php">

I'm not so familiar with the code suggested, should I be using:

<input type="hidden" name ="responderurl" value="http://www.mydomain.com/index.php'?' . urlencode(session_name()) . '=' . urlencode(session_id())">

Thanks,

Rob.
User avatar
Ragnis
Forum Commoner
Posts: 31
Joined: Thu Nov 13, 2008 12:35 pm
Location: Saaremaa, Estonia, Europe, Asia, Planet Earth, The Solar System, Milky way.

Re: Session Variable Life?

Post by Ragnis »

Code: Select all

<input type="hidden" name ="responderurl" value="http://www.mydomain.com/index.php<?php echo '?' . urlencode(session_name()) . '=' . urlencode(session_id()); ?>">
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Re: Session Variable Life?

Post by spacebiscuit »

Excuse my ignorance, but what are the session_name and session_id - I do not remember setting either of these.

The session variable name is 'DEL' - but I am guessing that this is not either the session mae or id?

Thanks,

Rob.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Session Variable Life?

Post by Jonah Bron »

You don't usually set them, but you can. The default session name is defined in the php.ini config file. Session ID is a unique alphanumeric string assigned to a computer while viewing your site. The session name and id are usually stored in a cookie on the user's computer. Anything you put into the $_SESSION superglobal variable is stored on the server, and is associated with the user's session id.
Post Reply