session problem

Discussion in 'PHP' started by ameerulislam43, Sep 14, 2013.

  1. #1
    working on a bought login script and this line I can't figure out the meaning

    PHP Code:

    <?php ob_start(); ?>
    <?php include_once('classes/translate.class.php'); ?>
    <?php if (!isset($_SESSION)) session_start(); ?> <---- this logic is not making sense to me.

    It says if $_SESSION is not set then start session. My question is if $_SESSION is not set why would you want to start a session.. Shouldn't I start/ continue a session only if that is set.. Other wise any one would be able to log into my protected pages isn't it?
     
    ameerulislam43, Sep 14, 2013 IP
  2. kip

    kip Notable Member

    Messages:
    1,521
    Likes Received:
    80
    Best Answers:
    0
    Trophy Points:
    205
    #2
    If you "bought" this script, it's poorly written. There are plenty of free login scripts out there.
     
    kip, Sep 14, 2013 IP
  3. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
  4. kutchbhi

    kutchbhi Active Member

    Messages:
    130
    Likes Received:
    4
    Best Answers:
    2
    Trophy Points:
    70
    #4
    I am not sure i understand you correctly... but I think sessions are created for each user individually.
    So if (!isset($_SESSION)) session_start(); // means if there is no session for this user, then start a session for this particular user.
    There are things like session hijacking , but I know next to nothing about them. :)
    hth
     
    kutchbhi, Sep 15, 2013 IP
  5. Cafer

    Cafer Member

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #5
    <?php ob_start(); session_start(); ?>
    <?php include_once('classes/translate.class.php'); ?>
    Bu şekilde dener misin?
     
    Cafer, Sep 15, 2013 IP
  6. eritrea1

    eritrea1 Active Member

    Messages:
    182
    Likes Received:
    9
    Best Answers:
    2
    Trophy Points:
    70
    #6
    You are right. even if you start session `session_start()` then the global $_SESSION will still be empty, unless any value is assigned to it.
     
    eritrea1, Sep 15, 2013 IP