...

View Full Version : session_register or $_SESSION



kenny873
02-28-2003, 04:01 AM
I am using PHP 4.3 (the latest php)

i have heard that we should use $_SESSION rather than session_register to register a session...is it true?

also I should no longer use session_is_registered() or anything alike....i should use isset($_SESSION()) instead....

can anyone give comments about the usage of session in PHP4.3 or the latest version...

firepages
02-28-2003, 06:16 AM
yep , dont register sessions anymore just use the $_SESSION superglobals , its less code if nothing else + unsetting session variables is easier.
So just set & get it like a normal variable (remembering that its global)

depending on your php.ini configuration you may or may not have to use session_start() before using session variables .

kenny873
02-28-2003, 06:27 AM
AND, a big problem, i ran the following code and it is not working until i refresh it for few or more times...it said that DNS error and server is not found...why's that?

<?php
session_start();

$fromPage = "/kenny/item_details.php";

if (isset($_SESSION['userid'])){

?>
okay , YOU ARE LOGGED IN !!!
<a href="/kenny/TestSession/logout.php"> LOGOUT </a>
<?
} else {
?>
Not okay, You are not logged in !!!
<? } ?>

firepages
02-28-2003, 06:38 AM
Well not knowing if & how userid has been set its hard to say ..
debug with print_r();



<?php
session_start();

$fromPage = "/kenny/item_details.php";

echo '<pre>';
print_r($_SESSION); // has userid infact been set ?//
echo '</pre>';

if (isset($_SESSION['userid'])){

?>
okay , YOU ARE LOGGED IN !!!
<a href="/kenny/TestSession/logout.php"> LOGOUT </a>
<?
} else {
?>
Not okay, You are not logged in !!!
<? } ?>

kenny873
02-28-2003, 06:51 AM
the point is :

when i use session_start();
it seems like not working until I tried to refresh few times....even i didn't check for $_SESSION



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum