SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict Ghz's Avatar
    Join Date
    Jun 2002
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry I"M GETING MADDDDDDD

    hello there,
    What's wrong with this session code:
    PHP Code:
     <?php
     session_start
    ();
      
    session_register("logname");
      echo 
    $logname;
    ?>
    it gives me a blank page. I tried this as well:
    PHP Code:
     <?php
     session_start
    ();
      
    session_register("logname");
      echo 
    $_SESSION['logname'];
    ?>
    It also gives me a blank white page. What could be the problem? thanx in advance

  2. #2
    SitePoint Member
    Join Date
    Jul 2003
    Location
    Lexington, Kentucky
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You haven't set $logname to anything. Do you have globals on?
    Sam Powers
    www.ibc-lex.org

  3. #3
    + platinum's Avatar
    Join Date
    Jun 2001
    Location
    Adelaide, Australia
    Posts
    6,441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this - you actually need to give "logname" a value to print too

    PHP Code:
    <?php
    session_start
    ();
      
    $_SESSION['logname'] = 'hello';
      echo 
    $_SESSION['logname'];
    ?>

  4. #4
    SitePoint Addict CeleronXL's Avatar
    Join Date
    Dec 2002
    Location
    United States of America
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I never liked session_register and all of those other functions. Always confused me. I just set and unset $_SESSION['something'] variables. Much easier.
    So hold me when I'm here
    Right me when I'm wrong
    Hold me when I'm scared
    Love me when I'm gone.

  5. #5
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Ghz
    What's wrong with this session code:

    PHP Code:
     <?php
     session_start
    ();
      
    session_register("logname");
      echo 
    $_SESSION['logname'];
    ?>
    http://php.net/session
    Quote Originally Posted by PHP Manual
    Use of $_SESSION (or $HTTP_SESSION_VARS with PHP 4.0.6 or less) is recommended for improved security and code readablity. With $_SESSION, there is no need to use the session_register(), session_unregister(), session_is_registered() functions. Session variables are accessible like any other variables.
    Try:
    PHP Code:
    session_start();
    echo 
    $_SESSION['logname']; 
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.


Bookmarks

Posting Permissions

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