Connecting Tech Pros Worldwide Forums | Help | Site Map

cookie path problem

michel
Guest
 
Posts: n/a
#1: Jul 17 '05
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\public\prospects\logon\index.php on line 38


someone?

thanks in advance,

Michel



Erwin Moller
Guest
 
Posts: n/a
#2: Jul 17 '05

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\public\prospects\logon\index.php on line 38
>
>
> someone?
>
> thanks in advance,
>
> Michel[/color]

michel
Guest
 
Posts: n/a
#3: Jul 17 '05

re: cookie path problem


nope. exactly the same error....

Mich

"Erwin Moller"
<since_humans_read_this_I_am_spammed_too_much@spam yourself.com> wrote in
message news:40b31ed8$0$559$e4fe514c@news.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\public\prospects\logon\index.php on line 38
> >
> >
> > someone?
> >
> > thanks in advance,
> >
> > Michel[/color]
>[/color]


Pedro Graca
Guest
 
Posts: n/a
#4: Jul 17 '05

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]

http://www.php.net/setcookie

<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\public\prospects\logon\index.php 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 :
michel
Guest
 
Posts: n/a
#5: Jul 17 '05

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


Subhash
Guest
 
Posts: n/a
#6: Jul 17 '05

re: cookie path problem


"michel" <no@spam.please> wrote in message news:<c8v5im$c5c$1@news.cistron.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\public\prospects\logon\index.php on line 38
>
>
> someone?
>
> thanks in advance,
>
> Michel[/color]

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

-S
Closed Thread