[PHP] 2 Qs: Passing current URL with session and how to avoid session timeout???

2003-01-18 Thread -[ Rene Brehmer ]-
Hi gang

Been trying to figure out this session stuff, but since I was unable to
make the manual sample into something workable, I instead decided to
actually try and make the session do what I need it for: Passing the URL
of the caller page to the page that's being called.

1. Only I can't figure out if there's a function to just pull the current
URL and plop it into a session variable. The thing is that these pages are
all built by using a bunch of GET variables in the URL, so it would be
easiest to just do something like:

  $_SESSION['mother'] = $currentURL;

And then in the called, daughter, page do this:

a href=?php echo(\$_SESSION['mother']\) ?Get back to where you
came from/a

As the only other way I've found is to have it use the string-functions
and re-build the current URL throughout the if-tree that builds the page.
I need to pass the mother URL to the daughter pages because there's two
main entry-points into the daugther pages, and one of them can have 10-15
different states...

But how do you pull the current url? ParseURL just smacks it into an
array, and I'll then have to rebuild it anyway ... which makes it about
just as simple as running it through the if-tree. Whether or not the
session-id is inside the URL is not essential to me, but dunno if php
cares about it.

2. Since the above is required to function at all times, I need to
override the expiration time. I can't do it in the ini file, 'cause I
can't modify the server where it's to run, and it's set to 0 there... (not
sure if that means it expires right away, or not at all)

Anyway to do this???

TIA

Rene
-- 
Rene Brehmer

This message was written on 100% recycled spam.

Come see! My brand new site is now online!
http://www.metalbunny.net

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] 2 Qs: Passing current URL with session and how to avoid session timeout???

2003-01-18 Thread Cal Evans
I guess I'm dense this morning. In response to 1:

$_SESSION['mother']=$_SERVER['PHP_SELF'];

and then

a href=?PHP echo $_SESSION['mother'];?Go Back/a

or better yet...
a href=?PHP echo $_SERVER['PHP_SELF'];?Go Back/a

as to #2:
I usually just pass this kind of info around on the URL.

http://mypage.com/mypage.php?prevURL=http://mypage.com/lastpage.php

if I have to pass a full query string then I urlencode() it first and
urldecode() it on the other side.

This survives sessions expiring.
=C=

*
* Cal Evans
* Stay plugged into your audience.
* http://www.christianperformer.com
*


-Original Message-
From: -[ Rene Brehmer ]- [mailto:[EMAIL PROTECTED]]
Sent: Saturday, January 18, 2003 10:04 AM
To: [EMAIL PROTECTED]
Subject: [PHP] 2 Qs: Passing current URL with session and how to avoid
session timeout???


Hi gang

Been trying to figure out this session stuff, but since I was unable to
make the manual sample into something workable, I instead decided to
actually try and make the session do what I need it for: Passing the URL
of the caller page to the page that's being called.

1. Only I can't figure out if there's a function to just pull the current
URL and plop it into a session variable. The thing is that these pages are
all built by using a bunch of GET variables in the URL, so it would be
easiest to just do something like:

  $_SESSION['mother'] = $currentURL;

And then in the called, daughter, page do this:

a href=?php echo(\$_SESSION['mother']\) ?Get back to where you
came from/a

As the only other way I've found is to have it use the string-functions
and re-build the current URL throughout the if-tree that builds the page.
I need to pass the mother URL to the daughter pages because there's two
main entry-points into the daugther pages, and one of them can have 10-15
different states...

But how do you pull the current url? ParseURL just smacks it into an
array, and I'll then have to rebuild it anyway ... which makes it about
just as simple as running it through the if-tree. Whether or not the
session-id is inside the URL is not essential to me, but dunno if php
cares about it.

2. Since the above is required to function at all times, I need to
override the expiration time. I can't do it in the ini file, 'cause I
can't modify the server where it's to run, and it's set to 0 there... (not
sure if that means it expires right away, or not at all)

Anyway to do this???

TIA

Rene
--
Rene Brehmer

This message was written on 100% recycled spam.

Come see! My brand new site is now online!
http://www.metalbunny.net

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] 2 Qs: Passing current URL with session and how to avoid session timeout???

2003-01-18 Thread Chris Shiflett
--- Cal Evans [EMAIL PROTECTED] wrote:
 I usually just pass this kind of info around on the URL.
 

http://mypage.com/mypage.php?prevURL=http://mypage.com/lastpage.php
 
 if I have to pass a full query string then I urlencode()
 it first and urldecode() it on the other side.

Just as a bit of advice, you should always URL encode any
data you want to append to the URL like that. Also,
decoding it is superfluous, because the Web server will do
that for you (since URL data is supposed to be URL
encoded).

Chris

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] 2 Qs: Passing current URL with session and how to avoid session timeout???

2003-01-18 Thread John W. Holmes
1. You can create the current page with a combination of PHP_SELF,
QUERY_STRING, etc... Take a look at a phpinfo() page to see all of the
variables. 

2. You can use ini_set() in your code to change the settings for your
sessions or an .htaccess file if your on *nix. 

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/

 -Original Message-
 From: -[ Rene Brehmer ]- [mailto:[EMAIL PROTECTED]]
 Sent: Saturday, January 18, 2003 11:04 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] 2 Qs: Passing current URL with session and how to avoid
 session timeout???
 
 Hi gang
 
 Been trying to figure out this session stuff, but since I was unable
to
 make the manual sample into something workable, I instead decided to
 actually try and make the session do what I need it for: Passing the
URL
 of the caller page to the page that's being called.
 
 1. Only I can't figure out if there's a function to just pull the
current
 URL and plop it into a session variable. The thing is that these pages
are
 all built by using a bunch of GET variables in the URL, so it would be
 easiest to just do something like:
 
   $_SESSION['mother'] = $currentURL;
 
 And then in the called, daughter, page do this:
 
 a href=?php echo(\$_SESSION['mother']\) ?Get back to where you
 came from/a
 
 As the only other way I've found is to have it use the
string-functions
 and re-build the current URL throughout the if-tree that builds the
page.
 I need to pass the mother URL to the daughter pages because there's
two
 main entry-points into the daugther pages, and one of them can have
10-15
 different states...
 
 But how do you pull the current url? ParseURL just smacks it into an
 array, and I'll then have to rebuild it anyway ... which makes it
about
 just as simple as running it through the if-tree. Whether or not the
 session-id is inside the URL is not essential to me, but dunno if php
 cares about it.
 
 2. Since the above is required to function at all times, I need to
 override the expiration time. I can't do it in the ini file, 'cause I
 can't modify the server where it's to run, and it's set to 0 there...
(not
 sure if that means it expires right away, or not at all)
 
 Anyway to do this???
 
 TIA
 
 Rene
 --
 Rene Brehmer
 
 This message was written on 100% recycled spam.
 
 Come see! My brand new site is now online!
 http://www.metalbunny.net
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] 2 Qs: Passing current URL with session and how to avoid session timeout???

2003-01-18 Thread -[ Rene Brehmer ]-
Hi Cal Evans,

On Sat, 18 Jan 2003 10:17:01 -0600, you wrote about RE: [PHP] 2 Qs:
Passing current URL with session and how to avoid session timeout???
something that looked like this:

I guess I'm dense this morning. In response to 1:

$_SESSION['mother']=$_SERVER['PHP_SELF'];

Didn't know the server array existed ... where I'd find that in the
manual??? Only doc I've got to run from...

and then

a href=?PHP echo $_SESSION['mother'];?Go Back/a

or better yet...
a href=?PHP echo $_SERVER['PHP_SELF'];?Go Back/a

Wouldn't that produce a link to the current url, rather than the previous?

as to #2:
I usually just pass this kind of info around on the URL.

http://mypage.com/mypage.php?prevURL=http://mypage.com/lastpage.php

if I have to pass a full query string then I urlencode() it first and
urldecode() it on the other side.

I can't do that reliably, my URLs are simply too long on some occasions
... so the URL ends up getting the end cut off...

But apparently the sessions expiring isn't an issue afterall ... have had
the page loaded for several hours, and the recursive linkage still works
... Will have to upload to my webhost though before I can be absolutely
certain ... Retaining matching settings in my test-enviro is not entirely
possible because their Apache is older than mine...and they run with
globals on, and I design for them off, just to be safe...

Rene
-- 
Rene Brehmer

This message was written on 100% recycled spam.

Come see! My brand new site is now online!
http://www.metalbunny.net

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] 2 Qs: Passing current URL with session and how to avoid session timeout???

2003-01-18 Thread -[ Rene Brehmer ]-
Hi Justin French,

On Sun, 19 Jan 2003 12:01:45 +1100, you wrote about Re: [PHP] 2 Qs:
Passing current URL with session and how to avoid session timeout???
something that looked like this:

1. If you require the back button to work forever, then do not use sessions,
because they're not designed to be a forever thing.

I only need the session to pass the url on to the next page ... once there
the old URL will be written into the HTML code... The only reasons I need
to do it with sessions is because my urls are too long for the encoded url
to be transfered reliably within the url...

2. I do this sort of stuff by building my own URL from $_SERVER components:

I haven't found the server array in the manual (yet anyway), so I'm not
sure what exactly it is you're doing ... so a bit of 'splaining would be
nice ... I'm only on my 4th month of PHP'ing afterall ... 

?
$script = $_SERVER['PHP_SELF'];
$qs = $_SERVER['QUERY_STRING'];
$currentURL = base64_encode($script.?.$qs);
?

The reason why I base64_encode() it is so that the vars=values of the
previous page don't affect the next page.

I don't have that problem. Variables aren't reausable because I'm doing
divide and conquer design ... that way I can prevent the code from being
too complex and requiring to many variables to work. Thus my variables
differ from master page to master page, all the common ones are rewritten
on each page load (as it only controls the menu links to be linked
correctly up/down folder levels).

I the link to the second page might be something like:

a href=page.php?ref=?=$currentURL?click/a

on page.php, to establish a back button:

? $ref = base64_decode($ref) ?
a href=?=$ref?go back/a

3.  This way, the referring/mother URL is always attached to that URL... if
they bookmark it, of give it to a friend, it's always there... sessions
don't achieve this, and cookies usually can, apart from the usual cookie
problems.

Apparently the trans_sid being on (or 1 as it is) makes the sid transfer
correctly everytime, atleast with my current setup ... which is this:

On mother:

  $_SESSION['mother'] = girlz.php?locat=$loclist=$listyear=$year;

On child:
  
if ($name != ) {
  $backlink = div align=\center\a
href=\.$_SESSION['mother'].\ class=\bldlink\ title=\Get back to
where you came from\Back to where you came from/a/divbr /;
  echo($backlink);
}

And before you ask, the reason the backlink is in a variable is because
it's reused a couple times down the page.

The above is, of course, only part of the code. It checks for alot more
stuff in the child file. Still have to work out how to ensure that the
backlink will produce a workable return link even when the page is
launched without a call from a mother page...

But that'll have to wait until morning ... it's 4.45 AM here now ;-) ...
gotta get some snooze...

Rene

-- 
Rene Brehmer

This message was written on 100% recycled spam.

Come see! My brand new site is now online!
http://www.metalbunny.net

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php