Loading ...
Sorry, an error occurred while loading the content.

Re: [bang-phpug] session destroy problem

Expand Messages
  • kumar gaurav singh Sonu
    Make sure that you have set the following in php.ini session.save_path = :/ ; Whether to use cookies. session.use_cookies = 1 Then try this
    Message 1 of 7 , Mar 9, 2010
    • 0 Attachment
      Make sure that you have set the following in php.ini
      session.save_path = "<drive>:/<folder>"

      ; Whether to use cookies.
      session.use_cookies = 1

      Then try this code....I think after that you can easily solve your problem by yourself..
      best of luck..

      http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <title>Session Test</title>
      </head>

      <body>
      <?php
      session_start();
      if(isset($_SESSION['views']))
      $_SESSION['views'] = $_SESSION['views']+ 1;
      else
      $_SESSION['views'] = 1;

      echo "views = ". $_SESSION['views'];
      // if($_SESSION['views'] == 5)
      //unset($_SESSION['views']); -->
      if($_SESSION['views'] == 10)
      session_destroy();
      ?>
      </body>
      </html>

      ________________________________
      From: Amardeep <amardeep.sarkar@...>
      To: bang-phpug@yahoogroups.com
      Sent: Tue, March 9, 2010 4:45:58 PM
      Subject: Re: [bang-phpug] session destroy problem


      Do you have session_start( ); called in the logout page ?

      On Tue, Mar 9, 2010 at 1:18 PM, bhatavanti <bhatavanti@yahoo. com> wrote:

      >
      >
      > Hi,
      > I have started a session in login page and trying to destroy it on logout
      > page but I am getting foll warnings:
      >
      > Warning: session_destroy( ) [function.session- destroy]: Trying to destroy
      > uninitialized session in
      > /home/content/ a/g/a/agani/ html/G/Mithaiwal e/testing/ logout.php on line 2
      >
      > Warning: Cannot modify header information - headers already sent by (output
      > started at /home/content/ a/g/a/agani/ html/G/Mithaiwal e/testing/ logout.php: 2)
      > in /home/content/ a/g/a/agani/ html/G/Mithaiwal e/testing/ logout.php on line 3
      >
      > Please help
      >
      >
      >

      --
      Amardeep Sarkar

      [Non-text portions of this message have been removed]







      [Non-text portions of this message have been removed]
    • janakiraman
      Hi Kumar, Do you have started session_start() in your logout page. Before calling session_destroy() for destroying the current session.  The session_destroy()
      Message 2 of 7 , Mar 9, 2010
      • 0 Attachment
        Hi Kumar,

        Do you have started session_start() in your logout page. Before calling session_destroy() for destroying the current session.  The session_destroy() will delete the data associated with the current session only. Use session_unset() to delete all the global and session varaibles.

        Regards,
        Janakiraman.

        --- On Tue, 9/3/10, kumar gaurav singh Sonu <kr_gaurav651@...> wrote:

        From: kumar gaurav singh Sonu <kr_gaurav651@...>
        Subject: Re: [bang-phpug] session destroy problem
        To: bang-phpug@yahoogroups.com
        Date: Tuesday, 9 March, 2010, 7:54 PM







         









        Make sure that you have set the following in php.ini

        session.save_ path = "<drive>:/<folder> "



        ; Whether to use cookies.

        session.use_ cookies = 1



        Then try this code....I think after that you can easily solve your problem by yourself..

        best of luck..



        http://www.w3 org/TR/xhtml1/ DTD/xhtml1- transitional. dtd">

        <head>

        <meta http-equiv=" Content-Type" content="text/ html; charset=utf- 8" />

        <title>Session Test</title>

        </head>



        <body>

        <?php

        session_start( );

        if(isset($_SESSION[ 'views']) )

        $_SESSION['views' ] = $_SESSION['views' ]+ 1;

        else

        $_SESSION['views' ] = 1;



        echo "views = ". $_SESSION['views' ];

        // if($_SESSION[ 'views'] == 5)

        //unset($_SESSION[ 'views']) ; -->

        if($_SESSION[ 'views'] == 10)

        session_destroy( );

        ?>

        </body>

        </html>



        ____________ _________ _________ __

        From: Amardeep <amardeep.sarkar@ gmail.com>

        To: bang-phpug@yahoogro ups.com

        Sent: Tue, March 9, 2010 4:45:58 PM

        Subject: Re: [bang-phpug] session destroy problem



        Do you have session_start( ); called in the logout page ?



        On Tue, Mar 9, 2010 at 1:18 PM, bhatavanti <bhatavanti@ yahoo. com> wrote:



        >

        >

        > Hi,

        > I have started a session in login page and trying to destroy it on logout

        > page but I am getting foll warnings:

        >

        > Warning: session_destroy( ) [function.session- destroy]: Trying to destroy

        > uninitialized session in

        > /home/content/ a/g/a/agani/ html/G/Mithaiwal e/testing/ logout.php on line 2

        >

        > Warning: Cannot modify header information - headers already sent by (output

        > started at /home/content/ a/g/a/agani/ html/G/Mithaiwal e/testing/ logout.php: 2)

        > in /home/content/ a/g/a/agani/ html/G/Mithaiwal e/testing/ logout.php on line 3

        >

        > Please help

        >

        >

        >



        --

        Amardeep Sarkar



        [Non-text portions of this message have been removed]



        [Non-text portions of this message have been removed]























        Your Mail works best with the New Yahoo Optimized IE8. Get it NOW! http://downloads.yahoo.com/in/internetexplorer/

        [Non-text portions of this message have been removed]
      • kumar gaurav singh Sonu
        yes I do.....thanx for your concern..... Regards Kumar Gaurav Singh ________________________________ From: janakiraman To:
        Message 3 of 7 , Mar 10, 2010
        • 0 Attachment
          yes I do.....thanx for your concern.....

          Regards
          Kumar Gaurav Singh


          ________________________________
          From: janakiraman <jhon_311983@...>
          To: bang-phpug@yahoogroups.com
          Sent: Wed, March 10, 2010 8:43:46 AM
          Subject: Re: [bang-phpug] session destroy problem


          Hi Kumar,

          Do you have started session_start( ) in your logout page. Before calling session_destroy( ) for destroying the current session. The session_destroy( ) will delete the data associated with the current session only. Use session_unset( ) to delete all the global and session varaibles.

          Regards,
          Janakiraman.

          --- On Tue, 9/3/10, kumar gaurav singh Sonu <kr_gaurav651@ yahoo.com> wrote:

          From: kumar gaurav singh Sonu <kr_gaurav651@ yahoo.com>
          Subject: Re: [bang-phpug] session destroy problem
          To: bang-phpug@yahoogro ups.com
          Date: Tuesday, 9 March, 2010, 7:54 PM



          Make sure that you have set the following in php.ini

          session.save_ path = "<drive>:/<folder> "

          ; Whether to use cookies.

          session.use_ cookies = 1

          Then try this code....I think after that you can easily solve your problem by yourself..

          best of luck..

          http://www.w3. org/TR/xhtml1/ DTD/xhtml1- transitional. dtd">

          <head>

          <meta http-equiv=" Content-Type" content="text/ html; charset=utf- 8" />

          <title>Session Test</title>

          </head>

          <body>

          <?php

          session_start( );

          if(isset($_SESSION[ 'views']) )

          $_SESSION['views' ] = $_SESSION['views' ]+ 1;

          else

          $_SESSION['views' ] = 1;

          echo "views = ". $_SESSION['views' ];

          // if($_SESSION[ 'views'] == 5)

          //unset($_SESSION[ 'views']) ; -->

          if($_SESSION[ 'views'] == 10)

          session_destroy( );

          ?>

          </body>

          </html>

          ____________ _________ _________ __

          From: Amardeep <amardeep.sarkar@ gmail.com>

          To: bang-phpug@yahoogro ups.com

          Sent: Tue, March 9, 2010 4:45:58 PM

          Subject: Re: [bang-phpug] session destroy problem

          Do you have session_start( ); called in the logout page ?

          On Tue, Mar 9, 2010 at 1:18 PM, bhatavanti <bhatavanti@ yahoo. com> wrote:

          >

          >

          > Hi,

          > I have started a session in login page and trying to destroy it on logout

          > page but I am getting foll warnings:

          >

          > Warning: session_destroy( ) [function.session- destroy]: Trying to destroy

          > uninitialized session in

          > /home/content/ a/g/a/agani/ html/G/Mithaiwal e/testing/ logout.php on line 2

          >

          > Warning: Cannot modify header information - headers already sent by (output

          > started at /home/content/ a/g/a/agani/ html/G/Mithaiwal e/testing/ logout.php: 2)

          > in /home/content/ a/g/a/agani/ html/G/Mithaiwal e/testing/ logout.php on line 3

          >

          > Please help

          >

          >

          >

          --

          Amardeep Sarkar

          [Non-text portions of this message have been removed]

          [Non-text portions of this message have been removed]

          Your Mail works best with the New Yahoo Optimized IE8. Get it NOW! http://downloads. yahoo.com/ in/internetexplo rer/

          [Non-text portions of this message have been removed]







          [Non-text portions of this message have been removed]
        • mithun mandal
          Hi, I will discuss your 2 issue in this mail. when you send your page to browser, it will send in 2 parts. 1) header, which you can t see you website source
          Message 4 of 7 , Mar 10, 2010
          • 0 Attachment
            Hi,

            I will discuss your 2 issue in this mail.

            when you send your page to browser, it will send in 2 parts. 1) header, which you can't see you website source code. 2) Body, it may be html content or xml content or file.

            here you must send header before you send any body item.

            now there is very few function to send header. 1.) session_start, 2) session_destroy, 3) header, 4) setcookies

            1) as par php doc you must initialize session_start before sending any single character, as it will setup session and also send a cookies to browser.
            2) after initialize only you can destroy a session which will send destroy cookies and cleanup session.
            3) setcookies also need to send before any character send. header may send "location"/ redirect header. so you need to send cookies before header.
            4) header to send custom header to control you page output.


            Now Practice Note:

            1) use output buffering so you can send header always before body (use obstart function to do that.). Buffering will send header first.
            2) always initialize session at to top of your page. also you can use custom session control, but, you need to initialize before session start.

            I hope this note will help you in future too and all others who are new to this problem.

            regards
            Mithun Mandal,
            Freelance Web Developer










            ________________________________
            From: bhatavanti <bhatavanti@...>
            To: bang-phpug@yahoogroups.com
            Sent: Tue, 9 March, 2010 1:18:36 PM
            Subject: [bang-phpug] session destroy problem


            Hi,
            I have started a session in login page and trying to destroy it on logout page but I am getting foll warnings:

            Warning: session_destroy( ) [function.session- destroy]: Trying to destroy uninitialized session in /home/content/ a/g/a/agani/ html/G/Mithaiwal e/testing/ logout.php on line 2

            Warning: Cannot modify header information - headers already sent by (output started at /home/content/ a/g/a/agani/ html/G/Mithaiwal e/testing/ logout.php: 2) in /home/content/ a/g/a/agani/ html/G/Mithaiwal e/testing/ logout.php on line 3

            Please help





            The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. http://in.yahoo.com/

            [Non-text portions of this message have been removed]
          Your message has been successfully submitted and would be delivered to recipients shortly.