PHP Session Problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nick Young

    PHP Session Problem

    Hi All,

    I am trying to get to grips with PHP Sessions. I have a very simple
    logon script that works fine so long as the client allows cookies.
    However when they have cookes turned off (and I know some of them will
    do) it dosnt work. I have 2 simple scripts below for testing that dont
    work. I have tried various settings such as:

    ini_set('sessio n.use_trans_sid ', false); AND
    ini_set('sessio n.use_trans_sid ', true);
    ini_set("sessio n.use_cookies", 0);
    session_registe r("logged");
    etc...

    None seem to have any affect. The scripts I use for testing are below.
    When run with cookies disabled the page2 comes up with the error
    "Undefined index: logged .........". Am I being stupid here? Can
    anyone point out what I am doing wrong?

    ----------------------------

    page1.php

    <?php
    session_start() ;
    session_set_coo kie_params(0);
    $_SESSION['logged'] = 1;
    echo $_SESSION['logged'];
    ?>

    page2.php

    <?php
    session_start() ;
    echo $_SESSION['logged'];
    ?>

    ---------------

    Cheers,

    Nick
  • Moxley Stratton

    #2
    Re: PHP Session Problem

    Nick Young wrote:[color=blue][color=green]
    > > None seem to have any affect. The scripts I use for testing are below.[/color]
    > When run with cookies disabled the page2 comes up with the error
    > "Undefined index: logged .........". Am I being stupid here? Can
    > anyone point out what I am doing wrong?[/color]

    You have to hyperlink to page2 from page1 for the trans_sid to work. Are
    you doing that?

    page1.php
    <?php
    ini_set('sessio n.use_trans_sid ', true);
    session_start() ;
    <snip>
    ?>
    <a href="page2.php ">page2</a>

    When you run page1.php, look at the source code from your browser to see
    the URL of the link. Has it been changed to something like this:
    <a href="page2.php ?SID=a10921830a 9019283">page2</a>

    Starting with a fresh browser, you should always see this the first time
    page1.php is loaded, regardless whether cookies are enabled.

    ---
    Moxley
    moxleystratton. com

    Comment

    • Nick Young

      #3
      Re: PHP Session Problem

      Hi,

      Yep I am doing that but unless I do

      <a href="page2.php <?php echo SID ?>">page2</a>

      it wont pass the SID around. I have tried adding
      ini_set('sessio n.use_trans_sid ', true); which dosnt seem to have made
      any difference. I am wondering if it is my installation gone corrupt!!!

      Cheers,
      Nick

      Moxley Stratton mumbled on about the following on 22/05/2004 18:20:[color=blue]
      > Nick Young wrote:
      >[color=green][color=darkred]
      >> > None seem to have any affect. The scripts I use for testing are[/color]
      >> below. When run with cookies disabled the page2 comes up with the
      >> error "Undefined index: logged .........". Am I being stupid here?
      >> Can anyone point out what I am doing wrong?[/color]
      >
      >
      > You have to hyperlink to page2 from page1 for the trans_sid to work. Are
      > you doing that?
      >
      > page1.php
      > <?php
      > ini_set('sessio n.use_trans_sid ', true);
      > session_start() ;
      > <snip>
      > ?>
      > <a href="page2.php ">page2</a>
      >
      > When you run page1.php, look at the source code from your browser to see
      > the URL of the link. Has it been changed to something like this:
      > <a href="page2.php ?SID=a10921830a 9019283">page2</a>
      >
      > Starting with a fresh browser, you should always see this the first time
      > page1.php is loaded, regardless whether cookies are enabled.
      >
      > ---
      > Moxley
      > moxleystratton. com[/color]

      Comment

      • Chung Leong

        #4
        Re: PHP Session Problem


        "Nick Young" <nick_young@tal k21.com> wrote in message
        news:c8nrkk$ktj $1@titan.btinte rnet.com...[color=blue]
        > Hi All,
        >
        > I am trying to get to grips with PHP Sessions. I have a very simple
        > logon script that works fine so long as the client allows cookies.
        > However when they have cookes turned off (and I know some of them will
        > do) it dosnt work. I have 2 simple scripts below for testing that dont
        > work. I have tried various settings such as:
        >
        > ini_set('sessio n.use_trans_sid ', false); AND
        > ini_set('sessio n.use_trans_sid ', true);
        > ini_set("sessio n.use_cookies", 0);
        > session_registe r("logged");
        > etc...[/color]

        You can't change use_trans_sid using ini_set(). It has to be set in php.ini.


        Comment

        Working...