473,739 Members | 8,690 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading a 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.

Feb 6 '07 #1
29 3007

"Jerim79" <my***@hotmail. comkirjoitti
viestissä:11*** *************** ****@v45g2000cw v.googlegroups. com...
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?
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.
Feb 6 '07 #2
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).
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.
Feb 6 '07 #3
On Feb 6, 9:03 am, "P Pulkkinen"
<perttu.POISTAT AMA.pulkki...@P OISTATAMA.elisa net.fiwrote:
"Jerim79" <m...@hotmail.c omkirjoitti
viestissä:11707 73276.017695.16 2...@v45g2000cw v.googlegroups. com...
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?

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

Feb 6 '07 #4
So - if I understand right- situation is this:

- There are four printers.
- Those machines that are somewhere close to printer x, should be able to
communicate to php (when it's rendering the page) that all php-made-printing
from this page request goes to printer x, since it is server PHP that
prints, not the local machine.
- Your personnel - but nobody else - can move any computer to a new
location, that is, closer to another printer than before.
- That's why you need to be able to change easily that location info, that
is again permanent, until you decide move the computer again.

Question is then also, is the cookie right or only way to accomplish this?

Usually kiosks use kiosk mode of the browser. You can start the browser
with http://example.com?printer=a or http://example.com?printer=b etc.,
after that it would be php session variable that can hold the info on the
printer. Or cookie. You could have four shortcut icons on the desktop to
make the starting easy. You could name them in descriptive way:
START-HERE-WHEN-UR-CLOSE-2-PRINTER-X

May it be my stupidity, if I misunderstood you. I hope you find the solution
anyway.
Feb 6 '07 #5
Jerim79 wrote:
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.
You can use a cookie for this. But here's a suggestion - have a
password-protected admin page which sets the cookie. When they move the
computer, they have to log into the admin page and tell it which printer
to use.

This then sets the cookie, which is now available for the rest of your
pages. Of course, you would want to ensure that cookies are not cleared
when the browser shuts down - at least not for your site.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Feb 6 '07 #6
On Feb 6, 3:50 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
Jerim79 wrote:
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 thecookie. I want to set thecookiemanual ly, so I
don't need setcookie(). I see that in PHP it stores thecookiein
memory. Is there a way to have PHP just read acookiefrom 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 thecookiewhich 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 thecookie
to have it access the correct code so that it prints the correct
information in the correct format.

You can use acookiefor this. But here's a suggestion - have a
password-protected admin page which sets thecookie. When they move the
computer, they have to log into the admin page and tell it which printer
to use.

This then sets thecookie, which is now available for the rest of your
pages. Of course, you would want to ensure that cookies are not cleared
when the browser shuts down - at least not for your site.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attgl obal.net
=============== ===
I talked with my boss, and he is completely against the kiosk mode
(for whatever reason). Let's step back from the word cookie for a
minute.

We are going to have 4 "kiosk" style computers, each of which display
the same registration form on a remote server. As the customer fills
out the form, he may get redirected to other forms based on how he
answered (Multiple paths). The very last step for everyone, after
everything is filled out and the customer submits the form, we want to
have a small script on the server that accesses a file on the kiosk
computer. The script on the server will read the value and perform an
action based on that value.

Cookie is the word my boss threw out there. I don't see why it has to
be a cookie, if PHP can access a remote file on the "kiosk" machine
from the server. We don't want to pass the value with the URL, as he
would have to go back and change all the pages of the PHP form to
pickup the value and pass it along to the next page.

Feb 7 '07 #7
Jerim79 wrote:
On Feb 6, 3:50 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
>Jerim79 wrote:
>>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 thecookie. I want to set thecookiemanual ly, so I
don't need setcookie(). I see that in PHP it stores thecookiein
memory. Is there a way to have PHP just read acookiefrom 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 thecookiewhich 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 thecookie
to have it access the correct code so that it prints the correct
information in the correct format.
You can use acookiefor this. But here's a suggestion - have a
password-protected admin page which sets thecookie. When they move the
computer, they have to log into the admin page and tell it which printer
to use.

This then sets thecookie, which is now available for the rest of your
pages. Of course, you would want to ensure that cookies are not cleared
when the browser shuts down - at least not for your site.

--
============== ====
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attg lobal.net
============== ====

I talked with my boss, and he is completely against the kiosk mode
(for whatever reason). Let's step back from the word cookie for a
minute.

We are going to have 4 "kiosk" style computers, each of which display
the same registration form on a remote server. As the customer fills
out the form, he may get redirected to other forms based on how he
answered (Multiple paths). The very last step for everyone, after
everything is filled out and the customer submits the form, we want to
have a small script on the server that accesses a file on the kiosk
computer. The script on the server will read the value and perform an
action based on that value.
A problem here. The server cannot read a file on the client system.
This would be a huge security risk if it could be done.
Cookie is the word my boss threw out there. I don't see why it has to
be a cookie, if PHP can access a remote file on the "kiosk" machine
from the server. We don't want to pass the value with the URL, as he
would have to go back and change all the pages of the PHP form to
pickup the value and pass it along to the next page.
It about has to be a cookie because security prevents anything on the
server from reading anything on the client not sent directly by the
browser. And javascript cannot access files on the client computer, either.

Can you imagine what fun the hackers would have if there were a way to
read files on your computer when you visit a website?

So you're pretty much stuck with a cookie if you want something specific
to that machine.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Feb 7 '07 #8
On Feb 7, 10:17 am, Jerry Stuckle <jstuck...@attg lobal.netwrote:
Jerim79 wrote:
On Feb 6, 3:50 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
Jerim79 wrote:
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 thecookie. I want to set thecookiemanual ly, so I
don't need setcookie(). I see that in PHP it stores thecookiein
memory. Is there a way to have PHP just read acookiefrom 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 thecookiewhich 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 thecookie
to have it access the correct code so that it prints the correct
information in the correct format.
You can use acookiefor this. But here's a suggestion - have a
password-protected admin page which sets thecookie. When they move the
computer, they have to log into the admin page and tell it which printer
to use.
This then sets thecookie, which is now available for the rest of your
pages. Of course, you would want to ensure that cookies are not cleared
when the browser shuts down - at least not for your site.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attgl obal.net
=============== ===
I talked with my boss, and he is completely against the kiosk mode
(for whatever reason). Let's step back from the wordcookiefor a
minute.
We are going to have 4 "kiosk" style computers, each of which display
the same registration form on a remote server. As the customer fills
out the form, he may get redirected to other forms based on how he
answered (Multiple paths). The very last step for everyone, after
everything is filled out and the customer submits the form, we want to
have a small script on the server that accesses a file on the kiosk
computer. The script on the server will read the value and perform an
action based on that value.

A problem here. The server cannot read a file on the client system.
This would be a huge security risk if it could be done.
Cookieis the word my boss threw out there. I don't see why it has to
be acookie, if PHP can access a remote file on the "kiosk" machine
from the server. We don't want to pass the value with the URL, as he
would have to go back and change all the pages of the PHP form to
pickup the value and pass it along to the next page.

It about has to be acookiebecause security prevents anything on the
server from reading anything on the client not sent directly by the
browser. And javascript cannot access files on the client computer, either.

Can you imagine what fun the hackers would have if there were a way to
read files on your computer when you visit a website?

So you're pretty much stuck with acookieif you want something specific
to that machine.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attgl obal.net
=============== ===
Okay, so we are going with cookies. The problem I have is that I don't
know how to make PHP just read a cookie. I understand how to set a
cookie, and it is stored in memory, which then can be used throughout
the form. I even know how to set a time limit on a cookie to make it
stay on the kiosk computer, but again, we don't want to create the
cookie.

The problem is that I don't want to set a cookie. I want to just read
one that I create manually. Obviously, setting a cookie through our
PHP form would only be able to set one value for all four machines,
yet we want to have 4 different values. Is there a way to just read a
cookie without setting it through PHP?

Feb 7 '07 #9
Rik
Jerim79 <my***@hotmail. comwrote:
Okay, so we are going with cookies. The problem I have is that I don't
know how to make PHP just read a cookie.
It's in the $_COOKIE array.
--
Rik Wasmus
Feb 7 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
45301
by: kam bansal | last post by:
Hi all, Can javascript read a cookie from a different domain? Meaning, if my html page is running on "www.mydomain.com" and I goto another domain "www.another.com" to do some work, and then I come back, can I see the cookie that "www.another.com" created from my domain??? Any thoughts? ~Kam (^8*
14
3273
by: Alec S. | last post by:
Hi, I'm using JavaScript and Cookies for some customization in a web page. There may be several values in the cookie with names that are not known at runtime. I need a way of deleting them. For example, if my site is www.test.com and the cookie contains: label1 fob
0
1473
by: Serge | last post by:
Good Day Folks I'm using the following code when creating, reading, and removing a cookies. <% ' writing cookie Response.cookies("OracleLogin")("p_userid")="fcs_system" Response.cookies("OracleLogin")("p_password")="developfcs" 'Response.cookies("OracleLogin").domain="ocdsb.ca" %>
2
1438
by: jack | last post by:
HI . i have created a cookiie in one page and i am trying to get in other page .. but not getting to desired result. im able to create cookie and reade it in the same page but not able to get or read it on the redirected page .. below is my code .. webform1.aspx private void Button1_Click(object sender, System.EventArgs e)
9
5520
by: Mike Reed | last post by:
I must be having a "senile" day! I cannot recall, nor get to work, code to read a cookie's expiration date/time in an ASP page/VBScript. What am I missing? *** Sent via Developersdex http://www.developersdex.com ***
2
3591
by: Sean | last post by:
I am trying to read a cookie I set but I am not sure if I really set it correctly or I am not reading it correctly. I was given the following instructions to set the cookie. It appears to be working because in Firefox browser I see the cookie listed for my domain I have been searching everywhere to find information on reading the cookie value that I set. I used the following code I found which returns 'no cookiez' in spite of the...
3
2231
by: icanhelp33 | last post by:
I have a C# utility that runs in ASP website. when user logs in the ASP code writes the cookie. I am unable to read it in C# code. I am using Request.Cookies.Value.ToString() I can read the same cookie in ASP code. If I say Request.Cookies("CookieName") in ASP that works fine..
8
2064
by: LayneMitch via WebmasterKB.com | last post by:
I'm supposed to develop a page that asks info as form values and when you hit "submit" it takes you to a page that reads the values you entered into the first page and displays those values in a message. I can't seem to find where I'm going wrong. Here's the code: Setting Cookie and Form Page: <html><head><title>Problem3</title> <script type="text/javascript" src="core.js"></script> <script type="text/javascript">
0
1381
by: kgabrys | last post by:
I have an C# Windows application that is to connect to a remote HTTPS website, POST the login, then subsequently POST a file and get the response. There is plenty of code out there that shows this sort of thing, but the finesse of how you use the response HTML to create the needed session cookie for the next request. Here's what happens, I send a request, and reading the response, I get and parse out what would become the session cookie if I...
0
8969
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9266
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9209
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8215
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6754
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6054
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.