Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Feb 2003
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    session_register or $_SESSION

    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...

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    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 .
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #3
    New Coder
    Join Date
    Feb 2003
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Internet Explorer

    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 !!!
    <? } ?>

  • #4
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    Well not knowing if & how userid has been set its hard to say ..
    debug with print_r();

    PHP Code:
    <?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 !!! 
    <? ?>
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #5
    New Coder
    Join Date
    Feb 2003
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •