读一个cookie [英] Reading a cookie

查看:67
本文介绍了读一个cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确实在张贴前试图找到答案,所以这不是
膝跳反应。


我想要的是什么完成是有一个脚本打开一个

cookie,读取一个值,然后使用一个开关/案例对cookie中的该值进行基于

的操作。我想手动设置cookie,所以我

不需要setcookie()。我在PHP中看到它将cookie存储在

内存中。有没有办法让PHP只是从桌面上读取一个cookie

机器?是否必须先设置它?我最好用Javascript

这个吗?


情况是我们有4台电脑。我们还有4种不同的b $ b类型的专业打印机,每种打印机都有不同的功能。我们不知道哪台计算机将连接到哪台打印机,他们可能会定期关闭
。我们正在尝试开发一个简单的脚本

,它读取cookie的值,告诉它打印哪个打印机打印到打印机和打印什么。这样,我们可以根据需要轻松切换计算机

,并且只需更改cookie中的值

即可让它访问正确的代码以便打印正确格式的正确

信息。

I did try to find the answer to this before posting, so this isn''t a
knee jerk reaction.

What I am trying to accomplish is to have a script that opens a
cookie, reads a value, and then use a switch/case to take action based
on that value in the cookie. I want to set the cookie manually, so I
don''t need setcookie(). I see that in PHP it stores the cookie in
memory. Is there a way to have PHP just read a cookie from the desktop
machine? Does it have to set it first? Am I better off with Javascript
for this?

The situation is that we have 4 computers. We also have 4 different
types of specialty printers, each for a different function. We don''t
know which computer will be hooked up to which printer, and they may
be switched out routinely. We are trying to develop a simple script
that reads the value of the cookie which tells it which printer to
print to and what to print. This way, we can easily switch computers
around as needed, and will only need to change the value in the cookie
to have it access the correct code so that it prints the correct
information in the correct format.

推荐答案



" ; Jerim79" < my *** @ hotmail.comkirjoitti

viestiss?:11 ********************** @ v45g2000cwv.goo glegroups。 com ...

"Jerim79" <my***@hotmail.comkirjoitti
viestiss?:11**********************@v45g2000cwv.goo glegroups.com...

我想要完成的是一个脚本打开一个

cookie,读取一个值,然后使用开关/案例对cookie中的值进行基于

的操作。我想手动设置cookie,所以我

不需要setcookie()。我在PHP中看到它将cookie存储在

内存中。有没有办法让PHP只是从桌面上读取一个cookie

机器?是否必须先设置它?我最好用Javascript

这个吗?
What I am trying to accomplish is to have a script that opens a
cookie, reads a value, and then use a switch/case to take action based
on that value in the cookie. I want to set the cookie manually, so I
don''t need setcookie(). I see that in PHP it stores the cookie in
memory. Is there a way to have PHP just read a cookie from the desktop
machine? Does it have to set it first? Am I better off with Javascript
for this?



我希望我不要错过任何一点,但一般来说:


1)在页面#1 EITHER php在页面渲染过程中或客户端javascript

随时,甚至更晚,设置一个cookie。

2)人点击一个链接提交一个表格MOVE ON到第#2页在同一个域上。

3)在第2页上,使用php或客户端javascript读取该cookie并使用它获得一些乐趣(是不是这样)。


当然,即使两者都可以设置饼干并一起玩,但这不是

点。


没有对最终问题发表评论,但不知怎的,我觉得这需要写入来澄清。

I hope i don''t miss some point, but generally speaking:

1) On page #1 EITHER php during the page rendering OR client javascript
anytime, even later, SETS UP a cookie.
2) Person clicks a link submits a form to MOVE ON to page #2 on same domain.
3) On page #2 EITHER php OR client javascript READS that cookie and have
some fun with it (does it''s thing).

Of course even both can set cookies and have fun together, but that'' not the
point.

No comments on the final problem, but somehow i felt that this needed to be
written to clarify.



我希望我不要错过任何一点,但一般来说:


1)在页面#1页面呈现或客户端javascript

随时,甚至更晚,设置一个cookie。

2)人cli cks链接提交一个表单到MOVE ON到同一个

域的第2页。

3)在页面#2上使用php或客户端javascript读取该cookie并拥有

一些有趣的事情(这是件事)。
I hope i don''t miss some point, but generally speaking:

1) On page #1 EITHER php during the page rendering OR client javascript
anytime, even later, SETS UP a cookie.
2) Person clicks a link submits a form to MOVE ON to page #2 on same
domain.
3) On page #2 EITHER php OR client javascript READS that cookie and have
some fun with it (does it''s thing).



但当然需要补充的是,我认为,ajax可以提供更多

玩饼干的机会,因为php调用是不限于

初始页面渲染。

But of course it needs to be added that ajax, i believe, gives more
opportunities to play with cookies, since php calls are not restricted to
initial page rendering.


2月6日上午9:03,P Pulkkinen

< perttu.POISTATAMA.pulkki ... @ POISTATAMA.elisanet.f iwrote:
On Feb 6, 9:03 am, "P Pulkkinen"
<perttu.POISTATAMA.pulkki...@POISTATAMA.elisanet.f iwrote:

" Jerim79" < m ... @ hotmail.comkirjoitti

viestiss?:1170773276.017695.162 ... @ v45g2000cwv.goo glegroups.com ...
"Jerim79" <m...@hotmail.comkirjoitti
viestiss?:1170773276.017695.162...@v45g2000cwv.goo glegroups.com...

我想要完成的是有一个脚本打开一个

cookie,读取一个值,然后使用一个开关/案例来采取行动

关于cookie中的那个值。我想手动设置cookie,所以我

不需要setcookie()。我在PHP中看到它将cookie存储在

内存中。有没有办法让PHP只是从桌面上读取一个cookie

机器?是否必须先设置它?我最好用Javascript

这个吗?
What I am trying to accomplish is to have a script that opens a
cookie, reads a value, and then use a switch/case to take action based
on that value in the cookie. I want to set the cookie manually, so I
don''t need setcookie(). I see that in PHP it stores the cookie in
memory. Is there a way to have PHP just read a cookie from the desktop
machine? Does it have to set it first? Am I better off with Javascript
for this?



我希望我不要错过任何一点,但一般来说:


1)第1页上的EITHER php在页面渲染过程中或客户端javascript

随时,甚至更晚,设置一个cookie。

2)人点击一个链接提交一个表格MOVE ON到第#2页在同一个域上。

3)在第2页上,使用php或客户端javascript读取该cookie并使用它获得一些乐趣(是不是这样)。


当然,即使两者都可以设置饼干并一起玩,但这不是

点。


没有对最终问题发表评论,但不知怎的,我觉得这需要写成澄清的b $ b。


I hope i don''t miss some point, but generally speaking:

1) On page #1 EITHER php during the page rendering OR client javascript
anytime, even later, SETS UP a cookie.
2) Person clicks a link submits a form to MOVE ON to page #2 on same domain.
3) On page #2 EITHER php OR client javascript READS that cookie and have
some fun with it (does it''s thing).

Of course even both can set cookies and have fun together, but that'' not the
point.

No comments on the final problem, but somehow i felt that this needed to be
written to clarify.



不完全。我们将有一个简单的注册表格,客户

填写在售货亭。他们点击提交,客户完成。从

那里注册信息被发送到PHP脚本,该脚本首先在客户端计算机上打开一个cookie并读取值。接下来,它通过一个基于该值的开关/案例语句列表来运行



确定客户端计算机正在使用哪台打印机以及格式是什么格式
$ b需要打印的$ b(这是用于远程打印,可以打印到四个打印机之一)。这样,当我们将计算机移动到另一台打印机时,我们只需更改cookie中的值即可正确打印

。 (我们使用远程服务器进行数据收集,并使用
本地PC进行打印。)


因为每台打印机都不同,所以setcookie()方法不会因为它只能在四台机器上设置一个值而工作(除非我们

做了四个不同的脚本,这会让人感到困惑)。我们需要

能够为同一个cookie提供四个不同的值。我们还需要

才能在计算机移动时手动更改值。想想你在四台不同的计算机上创建的文件的
。每个文件都有相同名称的

,但其中有一个不同的字母; A,B,C或D.程序

在每台计算机上打开文件,读入A,B,C或D.然后它b / b
对是否采取行动该文件包含A,B,C或D.这就是我们用cookie尝试完成的
。我们不希望每次程序运行时都创建

文件,因为文件已经存在。

Not exactly.We will have a simple registration form that a customer
fills out at a kiosk. They click submit and the customer is done. From
there the registration info is sent to a PHP script which first opens
a cookie on the client computer and reads the value. Next, it runs
through a list of switch/case statements based on that value to
determine which printer the client computer is using and what format
it needs to print in (This is for remote printing, to one of four
possible printers). This way, when we move a computer to a different
printer, we just change the value in the cookie and it starts printing
correctly. (We are using a remote server for the data collection, and
local PC to print.)

Since each printer is different, the setcookie() method would not
work because it can only set one value across four machines (Unless we
did four different scripts, which would get confusing). We need to be
able to have four different values for the same cookie. We also need
to be able to manually change the value when the computer moves. Think
of a file that you create on four different computers. Each file has
the same name, but a different letter in it; A, B, C or D. The program
opens the file up on each computer, reads in A, B, C or D. Then it
takes action on whether the file contained A, B, C or D. That is what
we are trying to accomplish with cookies. We don''t want to create the
file each time the program runs, because the file is already there.


这篇关于读一个cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆