Re: Session management issues
| From: | Mike Flynn | Date: | Thu, 08 Nov 2001 15:49:37 +0000 |
| Subject: | Re: Session management issues | ||
| References: | 1 2 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-10299@lists.php.net to get a copy of this message | ||
SESSION_UID is not a variable IN the session. It's a variable that tracks the session. You don't need to access it, it's constantly changing. What you need to do is set a variable of your own.
Something like this on the first page:
session_start();
...
$USERID = 10;
session_register('USERID');
...
then on subsequent pages..
if (!session_is_registered('USER')) {
header("Location: error.php?ec=1");
exit;
}
else {
...
}
At 09:56 PM 11/8/2001 +1000, you wrote:
I have session problems too. This script is on the second page the session is set on the first if(!session_is_registered("SESSION_UID")) { header("Location: error.php?ec=1"); exit; } now even though the session is set this is redirecting me to error.php If i comment this out and run it, it works of course. uncomment it and it still works. How can it work the second time and not the first??? You need a session either way Brendon "Eric Pankoke" <epankoke@csdatasol.net> wrote in message news:5.1.0.14.0.20011025002418.00a30ae0@mail.csdatasol.net... There are two potential problems (unless, of course, there's more to your pages than what you're showing us). Do you put a session_start() at the top of each page? If not, you won't be able to share variables across pages. Also, are you sure the session id is getting passed to each page? If not, it will start a new session each time and your variables will never be registered. Also, you shouldn't need the second session_start() in the else block of the login page. At 11:28 AM 10/24/01 -0600, Jason McIntyre wrote:Hi there: I am using PHP 4+ and MySQL to manage access to secured areas on awebsite.My problem is that my session functions don't seem to be workingproperly.Even after I start and register a session variable, my function to check that session variable says that it doesn't exist. Help! Here are the scripts: Login page: <? require_once("db_con.php"); -creates the database connection require_once("user_auth.php"); - authenticates user in database session_start(); if($txtUsername && $txtPassword) { $result = login($txtUsername, $txtPassword);whoif (!$result) { header("Location: loginerror.php");} else { session_start(); session_register("valid_user"); $valid_user = $result; - this passes in the unique id of the personlogged in. header("Location: ../memberso/default.php?idccacon=".$valid_user);code} exit; }?> --------------------------------- Now if the user exists it opens the ...default.php page, which has this... <? require_once("valid_user.php"); check_valid_user(); - which is in the valid_user.php This is the function that is called. <? function check_valid_user() { global $valid_user; if (!session_is_registered("valid_user"))-- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net For additional commands, e-mail: php-windows-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.netheader("Location: ../secure/accesserror.php");} ?> thx! Jason -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net For additional commands, e-mail: php-windows-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net
-=- Mike Flynn - Burlington, VT -=-mike@mikeflynn.net http://www.mikeflynn.net/ * Give blood * ...maintaining lawns, watching televised sports, birthing children, listening to Top 40 music, and collecting stuffed animals...