Re: newbie cookie question
| From: | Tom | Date: | Mon, 04 Dec 2000 15:26:43 +0000 |
| Subject: | Re: newbie cookie question | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-4271@lists.php.net to get a copy of this message | ||
Sounds like your cookie is getting set (or at least has been set once!) but then is
expiring.
If you haven't already tried it, do something like this: -
if (!isset($user_id)) {
$token = md5(uniqid(rand()));
setcookie("user_id",$token,"","/");
}
which sets a cookie (if it is not already set), makes it available to all directories
and hosts and keeps it alive until you kill the browser session. (Note that this
cookie is not all that useful except fro tracking a browser session, all it does is
slap a random number into the cookie which can then (hopefully) be used as a unique
identifier for the rest of the session).
Tom
Larry Hotchkiss wrote:
> Thanks for the heads up Tom. What I am doing is pulling up a form, posting
> the user/pass combo to a *.php which in turn authenticates and based on
> weather it succeeds or fails in turn sends header info to bring up an
> appropriate web page. On successfull authentication, I am simply trying to
> user the $cookie_user that I just set to do another query and display some
> of the users data. However, even though $cookie_user is written to the
> cookies.txt file I am not getting anything returned. I checked for the
> track_vars in the ini file and in 4.03 its default to on so I dont know
> where to go from here.
>
> Larry
>
> On Monday, December 04, 2000 4:01 AM, Tom [SMTP:tom.mathews@st.com] wrote:
> > Something else to be sure of is that the header form is correct - make
> sure that
> > you set the cookie before you send any text to the browser!
> >
> > Tom
> >
> > Zak Greant wrote:
> >
> > > Ok - we can be sure that the cookie is not getting set. Take Jayme's
> > > suggestion and make a more complete call to setcookie - the manual page
> on
> > > the function has good examples.
> > >
> > > Once you get the cookie to set, everything should be fine. :)
> > >
> > > If you can't get the cookie to set, write again.
> > >
> > > Good Luck!
> > >
> > > Zak
> > >
> > > PS Please keep your questions on the list - it is better for everyone
> that
> > > way. You get better answers to your questions and everyone else gets
> to
> > > benefit from them.
> > >
> > > At 04:04 PM 12/1/00 -0600, you wrote:
> > > > Nope, I dont see my cookie in there :-(. I fired up internet
> > > > explorere and seem to have the same problem as well.
> > > >
> > > >On Friday, December 01, 2000 3:34 PM, Zak Greant
> [SMTP:zak@nucleus.com] wrote:
> > > > > Check your cookies.txt file to see if the cookie is actually
> getting set.
> > > > > (Should be at a location on your system like: c:\program
> > > > > files\netscape\user\[your_user]]\cookies.txt)
> > > > >
> > > > > - zak
> > > > >
> > > > > At 03:20 PM 12/1/00 -0600, Larry Hotchkiss wrote:
> > > > > > Thanks for the input Zak, when I toss your code in I get
> the
> > > > > > following result:
> > > > > >
> > > > > >Array ( )
> > > > > >
> > > > > > And that is it. Any more ideas?
> > > > > >
> > > > > >Larry Hotchkiss
> > > > > >
> > > > > >On Friday, December 01, 2000 3:18 PM, Zak Greant
> > > > [SMTP:zak@nucleus.com] wrote:
> > > > > > > At 03:07 PM 12/1/00 -0600, you wrote:
> > > > > > > >I am just playing around at the moment and I have a script
> that sets a
> > > > > > > >couple of cookies. I am verifying that the cookies are set by
> > > > checking the
> > > > > > > >"warn me before accepting cookie" option in the
> > > > > > > >netscape
> browser. I
> > > > > > see the
> > > > > > > >cookie being set as well as its value. Now, I am under the
> > > > impression that
> > > > > > > >if my cookie code appears as follows:
> > > > > > > >
> > > > > > > >setcookie("cookie_user",$form_user_id);
> > > > > > > >
> > > > > > > > I should be able to access the data within the
> > > > > > > > cookie
> as
> > > > > > > > $cookie_user.
> > > > > > > >After entering data and having it saved to a cookie another
> page
> > > > is called
> > > > > > > >where I am simply trying to display the $form_user_id by
> > > > > > > >doing
> the
> > > > > > > >following:
> > > > > > > >
> > > > > > > >echo ("Welcome: $cookie_user");
> > > > > > > >
> > > > > > > > I get the welcome portion, but $cookie_user seems to
> be
> > > > > > > > unavailable. Any
> > > > > > > >ideas as to what I am obviously overlooking?
> > > > > > >
> > > > > > > The cookie variables may not be global. If there are any cookie
> > > > vars, they
> > > > > > > should be in the $HTTP_COOKIE_VARS array - try this little test
> to see
> > > > > > what
> > > > > > > is stored in there:
> > > > > > > <pre><? print_r ($HTTP_COOKIE_VARS)
> > > > > > > ?></pre>
> > > > > > >
> > > > > > > hth,
> > > > > > >
> > > > > > > zak
> > > > > >
> > > > > >
> > > > > >--
> > > > > >PHP Windows Mailing List (http://www.php.net/)
> > > > > >To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net
> > > > > >For additional commands, e-mail: php-windows-help@lists.php.net
> > > > > >To contact the list administrators, e-mail:
> php-list-admin@lists.php.net
> > >
> > > --
> > > PHP Windows Mailing List (http://www.php.net/)
> > > To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net
> > > For additional commands, e-mail: php-windows-help@lists.php.net
> > > To contact the list administrators, e-mail:
> php-list-admin@lists.php.net
> >
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-windows-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net
> For additional commands, e-mail: php-windows-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net