cookie path problem

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

    cookie path problem

    Hi all,

    A simple problem that requires a simple solution and I should be able and
    read php.net.... but can someone please help me out for a sec?

    I need to store a cookie and read it from a different path.

    using:

    setcookie('pros ','$data','/');

    to be able to read it from wherever on the same domain.
    What's wrong now. I get this:

    Warning: setcookie() expects parameter 3 to be long, string given in
    e:\phpdev\www\p ublic\prospects \logon\index.ph p on line 38


    someone?

    thanks in advance,

    Michel


  • Erwin Moller

    #2
    Re: cookie path problem

    michel wrote:
    [color=blue]
    > Hi all,
    >
    > A simple problem that requires a simple solution and I should be able and
    > read php.net.... but can someone please help me out for a sec?
    >
    > I need to store a cookie and read it from a different path.
    >
    > using:
    >
    > setcookie('pros ','$data','/');[/color]

    Does this help?

    setcookie("pros ","$data",'/');

    Regards,
    Erwin Moller
    [color=blue]
    >
    > to be able to read it from wherever on the same domain.
    > What's wrong now. I get this:
    >
    > Warning: setcookie() expects parameter 3 to be long, string given in
    > e:\phpdev\www\p ublic\prospects \logon\index.ph p on line 38
    >
    >
    > someone?
    >
    > thanks in advance,
    >
    > Michel[/color]

    Comment

    • michel

      #3
      Re: cookie path problem

      nope. exactly the same error....

      Mich

      "Erwin Moller"
      <since_humans_r ead_this_I_am_s pammed_too_much @spamyourself.c om> wrote in
      message news:40b31ed8$0 $559$e4fe514c@n ews.xs4all.nl.. .[color=blue]
      > michel wrote:
      >[color=green]
      > > Hi all,
      > >
      > > A simple problem that requires a simple solution and I should be able[/color][/color]
      and[color=blue][color=green]
      > > read php.net.... but can someone please help me out for a sec?
      > >
      > > I need to store a cookie and read it from a different path.
      > >
      > > using:
      > >
      > > setcookie('pros ','$data','/');[/color]
      >
      > Does this help?
      >
      > setcookie("pros ","$data",'/');
      >
      > Regards,
      > Erwin Moller
      >[color=green]
      > >
      > > to be able to read it from wherever on the same domain.
      > > What's wrong now. I get this:
      > >
      > > Warning: setcookie() expects parameter 3 to be long, string given in
      > > e:\phpdev\www\p ublic\prospects \logon\index.ph p on line 38
      > >
      > >
      > > someone?
      > >
      > > thanks in advance,
      > >
      > > Michel[/color]
      >[/color]


      Comment

      • Pedro Graca

        #4
        Re: cookie path problem

        michel wrote:[color=blue]
        > A simple problem that requires a simple solution and I should be able and
        > read php.net.... but can someone please help me out for a sec?[/color]



        <quote>
        bool setcookie ( string name [, string value [, int expire [, string
        path [, string domain [, int secure]]]]])
        </quote>
        [color=blue]
        > I need to store a cookie and read it from a different path.
        >
        > using:
        >
        > setcookie('pros ','$data','/');[/color]

        You are missing the expire parameter
        setcookie('pros ', '$data', $missing_expire _parameter, '/');

        Oh, and one more thing:
        Are you sure the string to set the cookie to is '$data'?

        That is five characters long starting with a literal dollar sign!
        [color=blue]
        > to be able to read it from wherever on the same domain.
        > What's wrong now. I get this:
        >
        > Warning: setcookie() expects parameter 3 to be long, string given in
        > e:\phpdev\www\p ublic\prospects \logon\index.ph p on line 38[/color]

        What a nice and *very descriptive* error message!
        Much better than, for example, "Syntax error near line 38"


        --
        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

        • michel

          #5
          Re: cookie path problem

          [color=blue]
          > You are missing the expire parameter
          > setcookie('pros ', '$data', $missing_expire _parameter, '/');
          >[/color]
          Yup.... that worked. Must have made a type when tryingg that before.
          [color=blue]
          > Oh, and one more thing:
          > Are you sure the string to set the cookie to is '$data'?
          >[/color]
          Deleted the quotes.... you're right. I didn't want that literally.
          Thanks for helping me out,

          Michel


          Comment

          • Subhash

            #6
            Re: cookie path problem

            "michel" <no@spam.please > wrote in message news:<c8v5im$c5 c$1@news.cistro n.nl>...[color=blue]
            > Hi all,
            >
            > A simple problem that requires a simple solution and I should be able and
            > read php.net.... but can someone please help me out for a sec?
            >
            > I need to store a cookie and read it from a different path.
            >
            > using:
            >
            > setcookie('pros ','$data','/');
            >
            > to be able to read it from wherever on the same domain.
            > What's wrong now. I get this:
            >
            > Warning: setcookie() expects parameter 3 to be long, string given in
            > e:\phpdev\www\p ublic\prospects \logon\index.ph p on line 38
            >
            >
            > someone?
            >
            > thanks in advance,
            >
            > Michel[/color]

            You are mising the expiration time!
            setcookie('pros ',$data,$time,'/');

            -S

            Comment

            Working...