Php session problem

Discussion in 'PHP' started by salman_k18, Oct 25, 2010.

  1. #1
    Hi ,

    I m working on site which does not allow me to initialize session i-e whenever i write session_start(); the page does not load ?????
     
    salman_k18, Oct 25, 2010 IP
  2. KingOle

    KingOle Peon

    Messages:
    69
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Do you output anything before you use session_start(); ? Including any whitespace? session_start(); needs to be at the top of your file before anything.
     
    KingOle, Oct 26, 2010 IP
  3. salman_k18

    salman_k18 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Its the first line of the page
     
    salman_k18, Oct 26, 2010 IP
  4. Om ji Kesharwani

    Om ji Kesharwani Peon

    Messages:
    211
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It doesnt mean that its written on first line check out the whitespace before it or check before starting session u r not sending any header information.
    i.e header("location....");
     
    Om ji Kesharwani, Oct 26, 2010 IP
  5. w47w47

    w47w47 Peon

    Messages:
    255
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    copy the code?
     
    w47w47, Oct 26, 2010 IP
  6. salman_k18

    salman_k18 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Ok i have checked it, no white spaces, no output
     
    salman_k18, Oct 26, 2010 IP
  7. w47w47

    w47w47 Peon

    Messages:
    255
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    or just copy the commands you use to initialize the sessions.

    you can just make a simple test to check if it's working...

    session_start();
    $_SESSION['test']='It is working';
    echo $_SESSION['test'];

    if this doesn't work... then you maybe have something configured in your http server wrong (apache or lighttpd)... like the temp directory for sessions has not the right permissions, etc.
     
    w47w47, Oct 26, 2010 IP
  8. salman_k18

    salman_k18 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I uploaded it on the live server and here is the error

    Warning: ini_set() [function.ini-set]: A session is active. You cannot change the session module's ini settings at this time in /home/content/g/o/t/gotbeatz/html/sign-up.php on line 3

    Line 3 : ini_set('session.use_trans_sid', '0');
     
    salman_k18, Oct 26, 2010 IP
  9. Sparaker

    Sparaker Peon

    Messages:
    204
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Well the error means that you already have a current session open on that browser and thus you can't change the ini setting.
     
    Sparaker, Oct 26, 2010 IP
  10. salman_k18

    salman_k18 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Ok thx.am i required to mark this as answer somewhere ??
     
    salman_k18, Oct 26, 2010 IP