Re: Passing variables
| From: | Jim lucas | Date: | Mon, 08 Jul 2002 15:19:16 +0000 |
| Subject: | Re: Passing variables | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-106093@lists.php.net to get a copy of this message | ||
Because the session is not being started on the second page. to be able to
get the contents of a variable that is in a session environment, you must
first initiate sessions with the call session_start(); even if that is all
you do before referancing the varialble.
so, add session_start(); just after entering the second script and is should
work. if it doesn't, if you have php 4.1.0 or newer use $_SESSION['course']
if older version you are working with, use $HTTP_SESSION_VARS['course'] .
Hope this helps.
Jim Lucas
----- Original Message -----
From: "Anthony Rodriguez" <sbwi@bellatlantic.net>
To: <php-general@lists.php.net>
Sent: Monday, July 08, 2002 5:40 AM
Subject: [PHP] Passing variables
> Dear Justin,
>
> After reading Kevin Yank's "Managing Users ..." at www.sitepoint.com, I
> tried the following 2 scripts. Unfortunately, the variable $course is NOT
> being passed to the 2nd script. Thus, per the script, the Home page is
> displayed. Why?
>
> --- 1st script ---
>
> <?php
> // file: "root/reg_users_2.php", updated: 07/08/02
> set_time_limit(300);
> session_start();
> session_register("course");
> $course="stats_101";
> header ("location:estadisticas/contents.php");
> flush();
> exit;
> ?>
>
> --- 2nd script ---
>
> <?php
> // file: "root/estadisticas/contents.php", updated: 07/06/02
> set_time_limit(300);
> if ($course!="stats_101")
> {
> header("location:../index.htm"); // Home page
> flush();
> exit;
> }
> else
> {
> echo "
> <html>
>
> --- HTML code here ---
>
> </html>
>
> ";
> };
> flush();
> exit;
> ?>
>
> Thanks!
>
> Tony
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>