#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    3
    Rep Power
    0
    I made session auto set ,auto transfer, and source as following:

    //first page
    <?php
    //session_start();
    $my_session_var="HelloWorld!";
    session_register( "my_session_var");
    print "variable = $my_session_var"."<HR>";
    print session_id();
    ?>
    <hr><a href="next.php">Go to nextpage</a>

    (output as following)
    variable = HelloWorld!
    -------------------------------------
    5fcb459c28b7f14184793ea5e8e86c29
    -------------------------------------
    Go to nextpage
    (/output)

    so far so good, next page source:

    <?php
    //session_start();
    print "variable= $my_session_var ";
    print "<HR>";
    print session_id();
    ?>

    (output)
    variable=
    -------------------------------------
    5fcb459c28b7f14184793ea5e8e86c29
    (/output)


    I dont understand, if I set a session variable, is'nt that means i can use it again
    and again in different page?
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    <<I dont understand, if I set a session variable, is'nt that means i can use it again
    and again in different page?
    >>


    yea,you can use that session variable again and again in different page.but before using the varible.you should use session_start();


    eg:

    first.php
    <?php

    session_start();
    $session_var = "Shiju";
    session_register( "session_var");
    //this will set the value to the session variable.
    ?>

    showme.php

    <?php

    session_start();
    print "My Name Is $session_var";
    ?>




    ------------------
    SR -
    shiju.dreamcenter.net

    "The fear of the LORD is the beginning of knowledge..."
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    3
    Rep Power
    0
    although I set PHP to "session.auto_start" by edit php.ini ,i still add

    <? session_start()?>

    and session variable still not work, i've tried apache_win32+PHP_win32 ,it work! But not work in my Redhat6.1 or FreeBSD 4.0 ,
    HELP!!!
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    30
    Rep Power
    14
    I would suggest removing session auto start and just adding session_start(); to the beginning of your page. I would also suggest stopping and restarting the webserver after you make your php.ini changes. I'm not sure if that makes a difference or not, but it couldn't hurt.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Location
    Oslo, Norway
    Posts
    5
    Rep Power
    0
    I used to have this problem too when I tested on the localhost. Make sure you use 127.0.0.1 instead of localhost. Netscape doesnt seem to store the cookie when localhost is used.

    N.
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    2
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by hanger:
    although I set PHP to "session.auto_start" by edit php.ini ,i still add

    <? session_start()?>

    and session variable still not work, i've tried apache_win32+PHP_win32 ,it work! But not work in my Redhat6.1 or FreeBSD 4.0 ,
    HELP!!!
    [/quote]

    I used to have a similar problem, the only thing that I have done after installing is editing the php.ini, so I thought of disabling it temporaly, and it worked, may be you have mispelled something there, try it. good luck
    --
    salih
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Posts
    5
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by salih:
    I used to have a similar problem, the only thing that I have done after installing is editing the php.ini, so I thought of disabling it temporaly, and it worked, may be you have mispelled something there, try it. good luck
    --
    salih
    [/quote]

    Actually, all you need to do to enable sessions on Windows and PHP4 is set register_globals = On in php.ini.

    --Bruce

Similar Threads

  1. Store part of URL in session variable?
    By Jonny5uk in forum ASP Programming
    Replies: 4
    Last Post: February 13th, 2004, 07:34 AM
  2. session object variable problem... urgent plz
    By hatembr in forum ASP Programming
    Replies: 2
    Last Post: February 11th, 2004, 02:14 AM
  3. session variable trashed
    By jubitzu in forum PHP Development
    Replies: 2
    Last Post: February 2nd, 2004, 01:17 PM
  4. Replies: 8
    Last Post: January 29th, 2004, 11:45 AM
  5. Using session variables instead of cookie variable
    By sargent1 in forum PHP Development
    Replies: 1
    Last Post: January 24th, 2004, 04:29 PM

IMN logo majestic logo threadwatch logo seochat tools logo