Problem using $_SESSION

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

    Problem using $_SESSION

    Hello all,

    I wondered if anyone could offer me some guidance, I wrote this script
    using the dzsoft php editor, which links to php.exe and a internal
    server.

    Though when I run the code the session files are created, but the item
    number in the files never increase beyond (0).

    I just wondered if there was anyone options in the php.ini I could
    change, to allow this premission. Or any session option I could add to
    the code.

    Many thanks

    <?php
    error_reporting (E_ALL);
    ini_set('displa y_errors', '1');

    session_save_pa th('c:\\');
    session_start() ;
    if (!isset($_SESSI ON['item1'])) $_SESSION['item1'] = 0;
    if (!isset($_SESSI ON['item2'])) $_SESSION['item2'] = 0;

    if(isset($_GET['Item1'])){
    $_SESSION['item1']++;
    }
    if(isset($_GET['Item2'])){
    $_SESSION['item2']++;
    }
    ?>

    <html>
    <head>
    <title>Test Page</title>
    </head>

    <body>

    <form>
    <input type="submit" name="Item1" value="Item 1">
    <input type="submit" name="Item2" value="Item 2">

    <p>Number of Item 1 clicks: <?php echo $_SESSION['item1']; ?></p>
    <p>Number of Item 2 clicks: <?php echo $_SESSION['item2']; ?></p>
    </form>

    </body>
    </html>
  • Virgil Green

    #2
    Re: Problem using $_SESSION

    "Antoni" <AntoniRyszard@ aol.com> wrote in message
    news:9359a333.0 406041305.48d00 d89@posting.goo gle.com...[color=blue]
    > Hello all,
    >
    > I wondered if anyone could offer me some guidance, I wrote this script
    > using the dzsoft php editor, which links to php.exe and a internal
    > server.
    >
    > Though when I run the code the session files are created, but the item
    > number in the files never increase beyond (0).
    >
    > I just wondered if there was anyone options in the php.ini I could
    > change, to allow this premission. Or any session option I could add to
    > the code.
    >
    > Many thanks
    >
    > <?php
    > error_reporting (E_ALL);
    > ini_set('displa y_errors', '1');
    >
    > session_save_pa th('c:\\');[/color]

    Here, you set the session save path, but what are the rest of your session
    settings in the php.ini file? Using cookies? Rewriting? Did your URL get
    rewritten on the first submission?

    Come to think of it... and I haven't tested... the initial URL re-writing
    (necessary until it is determined whether the cookie (if used) will be
    accepted) might not occur if you have no action parameter on your form tag.
    I haven't ever coded that way and haven't tried it.

    - Virgil


    Comment

    • Guest's Avatar

      #3
      Re: Problem using $_SESSION

      > Though when I run the code the session files are created, but the item[color=blue]
      > number in the files never increase beyond (0).[/color]

      Well, from the code you provided, I can tell you that there is no problem
      with the code. Whatever is happening is caused by some configuration issues.

      Things to check in php.ini

      session.auto_st art
      session.use_coo kies
      session.use_onl y_cookies
      session.use_tra ns_sid
      session.referer _check (this can be tough to track down but is a lot of times
      a problem)

      Aside from that, you may need to check your browser settings and see if your
      security is too high..

      _______________ _______________ ______
      Wil Moore III, MCP | Integrations Specialist |
      Assistant Webmaster Realnet Software | Homecomps.com


      Comment

      • Tim Van Wassenhove

        #4
        Re: Problem using $_SESSION

        In article <9359a333.04060 41305.48d00d89@ posting.google. com>, Antoni wrote:[color=blue]
        ><?php
        > error_reporting (E_ALL);
        > ini_set('displa y_errors', '1');
        >
        > session_save_pa th('c:\\');[/color]

        Try it with session_save_pa th('C:/'); or 'C:\' or "C:\\"


        --
        Tim Van Wassenhove <http://home.mysth.be/~timvw/contact.php>

        Comment

        • Pertti Kosunen

          #5
          Re: Problem using $_SESSION

          "Tim Van Wassenhove" <euki@pi.be> wrote in message
          news:2icrtdFlrp 2dU2@uni-berlin.de...[color=blue]
          > Try it with session_save_pa th('C:/'); or 'C:\' or "C:\\"[/color]

          C:\Temp or some other temporary directory would be better place.


          Comment

          • Pedro Graca

            #6
            Re: Problem using $_SESSION

            Antoni wrote:
            (snip)[color=blue]
            ><body>
            >
            ><form>[/color]

            As Virgil said, try

            <form action="<?php echo $_SERVER['PHP_SELF']; ?>">

            instead of your plain "<form>"

            --
            USENET would be a better place if everybody read: : mail address :
            http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
            http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
            http://www.expita.com/nomime.html : to 10K bytes :

            Comment

            • Dan Hill

              #7
              Re: Problem using $_SESSION

              Hello!
              I have the following:
              Apache/2.0.49 (Debian GNU/Linux) PHP/4.3.4 Server at xxx Port 80
              from apache2-mpm-prefork debian package, the newest available

              I've been messing with it for quite long and none of those details in
              the prior posts matter or at least You know they matter right away,
              when the error reporting is on. I have a friend with:
              Apache/1.3.31 and php4 on Gentoo
              and the scripts I have written are working there. I've been checking
              my php.ini with his one and there were some minor differences, I set
              those up to his values and restarted, but it still doesn't work. I
              have no session at all. No variables are defined, not even session
              constant PHPSESSID has a value.

              So my question is, what security configuration in server may cause
              this kind of behaviour?

              P.S. It's urgent

              Comment

              Working...