Help - Search - Member List - Calendar
Full Version: passing variables between php pages
WorkTheWeb Forums > Webmaster Resources > PHP Help
Support our Sponsors!
Hendry Taylor
If I have a php page that uses the header function to load a second php
page, how can I access variables defined in the first php page without
passing them via the url?

Andy Hassall
On Mon, 13 Jun 2005 21:01:00 +0000 (UTC), Hendry Taylor
<[Email Removed]> wrote:

QUOTE
If I have a php page that uses the header function to load a second php
page, how can I access variables defined in the first php page without
passing them via the url?

Cookies.
Sessions.

--
Andy Hassall / <[Email Removed]> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool

Lee David
I looked up Sessions in PHP fasts&easy web development and they looked pretty hard on the surface. Can you expanded on their usage a little?

Thanks,
Lee

"Andy Hassall" <[Email Removed]> wrote in message news:[Email Removed]...
QUOTE
On Mon, 13 Jun 2005 21:01:00 +0000 (UTC), Hendry Taylor
<[Email Removed]> wrote:

If I have a php page that uses the header function to load a second php
page, how can I access variables defined in the first php page without
passing them via the url?

Cookies.
Sessions.

--
Andy Hassall / <[Email Removed]> / <http://www.andyh.co.uk
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool


Chris Hope
Lee David wrote:

QUOTE
I looked up Sessions in PHP fasts&easy web development and they looked
pretty hard on the surface.  Can you expanded on their usage a little?

Did you try the manual? There's explainations there, examples and a lot
of user contributed notes.

http://www.php.net/manual/en/ref.session.php

--
Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com

Andy Hassall
On Mon, 13 Jun 2005 20:32:00 -0500, "Lee David"
<[Email Removed]> wrote:

QUOTE
I looked up Sessions in PHP fasts&easy web development and they looked pretty hard on the surface.  Can you expanded on their usage a little?

There's not much to them, at least for basic usage.

You call session_start() on every page.

You set a value in $_SESSION on one page.

The same value is then available on the next page.

http://php.net/session

--
Andy Hassall / <[Email Removed]> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool

Exyle
It depends on how you're going to be accessing the files. a simple
include() might do, or you can just have your links to the toher file
include the variable:
<a href='b.php?var=<?php echo($var); ?>'>Link</a>
if those methods wont work, then you can use cookies and sessions.

Hendry Taylor wrote:
QUOTE
If I have a php page that uses the header function to load a second php
page, how can I access variables defined in the first php page without
passing them via the url?



PHP Help | Linux Help | Web Hosting | Reseller Hosting | SSL Hosting
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2006 Invision Power Services, Inc.