if cookie is disabled then session will work or not???????????

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

    if cookie is disabled then session will work or not???????????

    hi

    i am using session in php. but if the client has disabled his cookie
    then will my session work or not?????????

    thxs for your reply in advance........ .....

  • Malcolm Dew-Jones

    #2
    Re: if cookie is disabled then session will work or not???????????

    vishal (vishal_panjabi @yahoo.co.in) wrote:
    : hi

    : i am using session in php. but if the client has disabled his cookie
    : then will my session work or not?????????

    : thxs for your reply in advance........ .....

    Please try it yourself and see. In general both possible answers can be
    true depending on the server.


    --

    This space not for rent.

    Comment

    • Peter Fox

      #3
      Re: if cookie is disabled then session will work or not???????????

      >vishal (vishal_panjabi @yahoo.co.in) wrote:[color=blue]
      >: hi
      >
      >: i am using session in php. but if the client has disabled his cookie
      >: then will my session work or not?????????[/color]

      Try picking the bones out of the following. This seems to work OK as
      far as I can test for Nutscrape and IE on my local and commercial web
      host. The first part is all about testing for cookies enabled. The
      second works out if to add the SID to the URL.


      //////////////////////////////////////
      /// Cookies //////////////////////////
      ///////////////////////////////////////


      #---------------------------------------------------------------------
      function COOKget($Varnam e){
      # Try to get value from the cookies array
      #---------------------------------------------------------------------
      $rv='';
      if (isset($_COOKIE[$Varname])){
      $rv = $_COOKIE[$Varname];
      }
      return $rv;
      }



      #---------------------------------------------------------------------
      function FlagCookies(){
      # Decide if we can use cookies
      # Set session var COOKIES 1=No 2=Yes
      # COOKIES var is used by GoTo()
      # This needs to be called twice on different page loads
      # (1 to set cookie 2 to test)
      # Eg once in login and once in main menu.
      # Or could be done on any consecutive pages
      # Or on single page ...
      # ---------------------
      # This returns TRUE if we are in the testing process and need to
      # do another call. Use this if there is a home page without a
      # definite sequence eg just a public main menu.
      # if FlagCookies(){G oto(<thispageag ain.php>);}
      #---------------------------------------------------------------------
      $rv = FALSE; // no need to do more testing
      $progress = SESget(COOKIES) ;
      if(!$progress){ // not started testing yet
      setcookie('test cookie','arecoo kiesenabled',ti me() - 600);
      SESset(COOKIES,-1); // testing - as yet unknown
      $rv = TRUE; // more work to do
      }else{
      if($progress==-1){
      $cook = COOKget('testco okie');
      if(!$cook){
      //print('no cookies');
      SESset(COOKIES, 1); // no
      }else{
      //print('cookies! ');
      SESset(COOKIES, 2); // yes
      }
      }
      }
      return $rv;
      }



      #---------------------------------------------------------------------
      function SESset($Varname ,$Varval){
      # Set session[{Varname}] to {Varval};
      #---------------------------------------------------------------------
      unset($_SESSION[$Varname]);
      $_SESSION[$Varname] = $Varval;
      }


      #---------------------------------------------------------------------
      function GoTo($NextPage, $Msg=''){
      # This does a header(location ...) to jump to another page
      # The optional 2nd parameter attaches ?msg=... to the URL
      # //NB If $NextPage is LASTRESORTBACKT O then take special action
      # // - We might be in a flying page with no back and so we
      # // want to close this window
      #---------------------------------------------------------------------
      if($NextPage==L ASTRESORTBACKTO ){
      $NextPage='clos er.htm';
      }

      if($Msg){
      $message='?msg= '.urlencode($Ms g);
      }else{
      $message='';
      }
      /* header("Locatio n: http://".$_SERVER['HTTP_HOST']
      .dirname($_SERV ER['PHP_SELF'])
      ."/".basename($Nex tPage).$message );
      */
      if(SESget(COOKI ES)==2){
      $s='';
      }else{
      $s='?'.SID;
      if($s=='?'){$s= '';}
      }
      $h="Location: ".basename($Nex tPage).$s.$mess age;
      header($h);
      exit;
      }








      --
      PETER FOX Not the same since the bottom fell out of the bucket business
      peterfox@eminen t.demon.co.uk.n ot.this.bit.no. html
      2 Tees Close, Witham, Essex.
      Gravity beer in Essex <http://www.eminent.dem on.co.uk>

      Comment

      • Andy Hassall

        #4
        Re: if cookie is disabled then session will work or not???????????

        On Sat, 12 Mar 2005 09:49:55 +0000, Peter Fox
        <peterfox@emine nt.demon.co.uk. not.this.bit.no .html> wrote:
        [color=blue][color=green]
        >>vishal (vishal_panjabi @yahoo.co.in) wrote:
        >>: hi
        >>
        >>: i am using session in php. but if the client has disabled his cookie
        >>: then will my session work or not?????????[/color]
        >
        >Try picking the bones out of the following. This seems to work OK as
        >far as I can test for Nutscrape and IE on my local and commercial web
        >host. The first part is all about testing for cookies enabled. The
        >second works out if to add the SID to the URL.[/color]

        Hm - isn't this basically re-inventing session.use_tra ns_sid?

        --
        Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
        <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

        Comment

        • R. Rajesh Jeba Anbiah

          #5
          Re: if cookie is disabled then session will work or not???????????

          Andy Hassall wrote:[color=blue]
          > On Sat, 12 Mar 2005 09:49:55 +0000, Peter Fox
          > <peterfox@emine nt.demon.co.uk. not.this.bit.no .html> wrote:[/color]
          <snip>[color=blue][color=green]
          > >Try picking the bones out of the following. This seems to work OK[/color][/color]
          as[color=blue][color=green]
          > >far as I can test for Nutscrape and IE on my local and commercial[/color][/color]
          web[color=blue][color=green]
          > >host. The first part is all about testing for cookies enabled. The[/color][/color]
          [color=blue][color=green]
          > >second works out if to add the SID to the URL.[/color]
          >
          > Hm - isn't this basically re-inventing session.use_tra ns_sid?[/color]

          Doesn't seem so--as he is just fiddling with the
          header('Locatio n:..')..

          --
          <?php echo 'Just another PHP saint'; ?>
          Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

          Comment

          • Peter Fox

            #6
            Re: if cookie is disabled then session will work or not???????????

            Following on from Andy Hassall's message. . .[color=blue]
            > Hm - isn't this basically re-inventing session.use_tra ns_sid?
            >[/color]
            Guilty m'lud.

            But there was a good reason ...
            .... lost in the mists of time.

            Possibly I needed to know rather than just have it do it itself. Or
            possibly the transparent addition was upsetting something else ... Don't
            know.
            --
            PETER FOX Not the same since the cardboard box company folded
            peterfox@eminen t.demon.co.uk.n ot.this.bit.no. html
            2 Tees Close, Witham, Essex.
            Gravity beer in Essex <http://www.eminent.dem on.co.uk>

            Comment

            Working...