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 2 of 2

Thread: session problem

  1. #1
    New Coder
    Join Date
    Mar 2004
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    session problem

    hi everyone,

    i am a newbie in php and facing a problem regarding cookies.

    i have following settings in my php.ini file:

    session.save_path = "C:\Program Files\Apache Group\Apache2\htdocs\tmp"

    session.use_cookies = 1
    session.cookie_lifetime = 0
    session.cookie_path = "C:\Program Files\Apache Group\Apache2\htdocs\cookies"
    session.cookie_domain =




    Earlier i had session.cookie_path = / ------default value, i changed it to the above mentioned cookies directory which is mentioned above.

    i dont know where is the default value for / session.cookie_lifetime = session.cookie_lifetime = / / pointing towards.

    now i am writing following code:

    <?php
    session_start();
    $val = setcookie("test_cookie","hello");

    if($Val == TRUE)
    echo "cookie set<br>";
    else
    echo "problem setting cookie";

    $cookie_val = $_COOKIE['test_cookie'];
    echo $cookie_val;
    ?>

    i get the output cookie set
    hello

    now when i go to cookie tmp directory according to the:
    session.save_path = "C:\Program Files\Apache Group\Apache2\htdocs\tmp" ---- i get the files having names like session ids (sess_20d809b36ece8a6c85ebd706532ddefc) when i double click the file and open with notepad i dont get the value which i had set using the setcookie function (i.e. hello).

    plz help me knowing how can i access cookies, where are they stored as i do not get any thing in cookies directory which i created for session.cookie_path setting.

    why am i not getting the hello value for cookie in the tmp directory session file.

    Thank you
    Gaurav

  • #2
    New Coder
    Join Date
    May 2003
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That is because you are not using a session, you are using a cookie.

    To use a session you use:
    $_SESSION['test_value'] = "Hello";
    cpCommerce - Finally a template based open-source e-commerce solution


  •  

    Posting Permissions

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