PHP Session problem. (and also cookie)

Discussion in 'PHP' started by Ri Genette, Oct 30, 2007.

  1. #1
    Hi, every body.
    I just started working with PHP, and I met problem on setting cookie and session.

    In order to set cookie, I used

    setcookie("risfname",$refl[0][3],time()+3600);

    But it doesn't work. When I get cookie by the "risfname", only empty string I can see.

    What's the matter?

    and with session, I used session_start(), some warning message occured.
    and to set information on session, I wrote

    session_start();
    session_register("risid");
    $_SESSION["risid"]=$refl[0][1];

    But also, I cann't get the data, only empty string.

    Pleas help me.

    Thank you.
     
    Ri Genette, Oct 30, 2007 IP
  2. Columbian

    Columbian Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    i think some servers need you to specify the save session path "session_save_path()"....i think
     
    Columbian, Oct 30, 2007 IP
  3. xemiterx

    xemiterx Peon

    Messages:
    62
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    A copy and paste of this warning message might prove useful to help you track down the problem.
     
    xemiterx, Oct 30, 2007 IP
  4. Columbian

    Columbian Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    so very true
     
    Columbian, Oct 30, 2007 IP
  5. Ri Genette

    Ri Genette Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thank you, Columbian.
    so can you explain to me how to specify the save path?
    If you have sample code, then can you show me?

    Thank you.

    genette.
     
    Ri Genette, Oct 30, 2007 IP
  6. Ri Genette

    Ri Genette Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thank you for your reply, xemiterx.
    But I can't get you. so which warning message copy to where, you mean?
    SOrry, I really don't understand.
    If you don't mind, more detail..

    Thank you.

    genette.
     
    Ri Genette, Oct 30, 2007 IP
  7. Lordy

    Lordy Peon

    Messages:
    1,643
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    0
    #7
    you said when oyu use session_start() you get some warning message.

    he is referencing that warning message

    are you sure $refl[0][1] isn't empty?
     
    Lordy, Oct 30, 2007 IP
  8. Ri Genette

    Ri Genette Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Yes, I am sure that they have certain values.
    So, thank you for you url, but I still cann`t get any solution.
    Have you got any solution for me, Lordy?

    Thank you.
    genette
     
    Ri Genette, Oct 31, 2007 IP
  9. Lordy

    Lordy Peon

    Messages:
    1,643
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    0
    #9
    how are you calling the cookie again?
     
    Lordy, Oct 31, 2007 IP
  10. Ri Genette

    Ri Genette Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    I set value on cookie:
    setcookie("risfname",$refl[0][3],time()+3600);
    but return value is False.

    And get it back :
    message($_COOKIE['risfname']);

    but shows "".

    So, what's the reason do you think, Lordy?
     
    Ri Genette, Oct 31, 2007 IP
  11. Ri Genette

    Ri Genette Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Hi, everybody.
    Thanks for your attention.
    So now I solved session problem. I can set session.
    BUt still not on cookie.
    Anybody have solution for set cookie?
    Expect advice on setting cookie.

    thank you.
    genette.
     
    Ri Genette, Nov 4, 2007 IP
  12. Kallisto

    Kallisto Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Hi!

    Your cookies will be work after reload your page only..

    Look example:
    
    <?
    setcookie("mycook", "hello", time()+60*60);
    var_dump($_COOKIE["mycook"]); // or echo $_COOKIE["mycook"];
    ?>
    
    Code (markup):
    you will receive empty string..

    but this code will be work
    
    <?
    if(!isset($_COOKIE["mycook"])) 
    {
    setcookie("mycook", "hello world", time()+60*60);
    echo "Cookie installed. Press F5 to view";
    }
    else
    echo $_COOKIE["mycook"];
    ?>
    
    Code (markup):
    Sorry for my english)
     
    Kallisto, Nov 4, 2007 IP