Hi, I am trying to set a cookie on a client computer using the Cookie
module however all I get is the text being printed in the browser
window. Can anyone point me in the right direction so that the cookie
data is set without it appearing in the browser? A shortened version
of the code is below, in the full version there is also userID check,
this seems to work ok. I have removed that portion for the time being
as its the writing part that is the problem.
import sys, os, string, cgi, Cookie, urllib2
from types import ListType
cookie = Cookie.SimpleCookie()
cookieHdr = os.environ.get("HTTP_COOKIE", "")
cookie.load(cookieHdr)
def writetocookie(number):
#writes the ID of the database entry to a cookie
cookie["dataid"]=number
print "Content-Type: text/html"
print
print "Set-Cookie: dataid=",cookie["dataid"].value
writetocookie(1)
I presume this is not the correct way to write a cookie, the examples
I have found online don't seem to provide much more information.
Kind regards,
rod 4 1239
En Wed, 06 Feb 2008 15:27:53 -0200, rodmc <us***************@yahoo.co.uk>
escribi�:
Hi, I am trying to set a cookie on a client computer using the Cookie
module however all I get is the text being printed in the browser
window. Can anyone point me in the right direction so that the cookie
def writetocookie(number):
#writes the ID of the database entry to a cookie
cookie["dataid"]=number
print "Content-Type: text/html"
print
print "Set-Cookie: dataid=",cookie["dataid"].value
I presume this is not the correct way to write a cookie, the examples
I have found online don't seem to provide much more information.
I don't know either if this is the right way, but surely the Set-Cookie
header must appear *before* the blank line; that blank line separates the
headers from the response body.
--
Gabriel Genellina
On Feb 6, 8:00 pm, "Gabriel Genellina" <gagsl-...@yahoo.com.arwrote:
En Wed, 06 Feb 2008 15:27:53 -0200, rodmc <userprogoogle-...@yahoo.co.uk>
escribi�:
Hi, I am trying to set a cookie on a client computer using the Cookie
module however all I get is the text being printed in the browser
window. Can anyone point me in the right direction so that the cookie
def writetocookie(number):
#writes the ID of the database entry to a cookie
cookie["dataid"]=number
print "Content-Type: text/html"
print
print "Set-Cookie: dataid=",cookie["dataid"].value
I presume this is not the correct way to write a cookie, the examples
I have found online don't seem to provide much more information.
I don't know either if this is the right way, but surely the Set-Cookie
header must appear *before* the blank line; that blank line separates the
headers from the response body.
--
Gabriel Genellina
Thanks, that seemed to work.
rod
On Feb 7, 1:06 pm, rodmc <userprogoogle-...@yahoo.co.ukwrote:
On Feb 6, 8:00 pm, "Gabriel Genellina" <gagsl-...@yahoo.com.arwrote:
En Wed, 06 Feb 2008 15:27:53 -0200, rodmc <userprogoogle-...@yahoo.co.uk>
escribi�:
Hi, I am trying to set a cookie on a client computer using the Cookie
module however all I get is the text being printed in the browser
window. Can anyone point me in the right direction so that the cookie
def writetocookie(number):
#writes the ID of the database entry to a cookie
cookie["dataid"]=number
print "Content-Type: text/html"
print
print "Set-Cookie: dataid=",cookie["dataid"].value
I presume this is not the correct way to write a cookie, the examples
I have found online don't seem to provide much more information.
I don't know either if this is the right way, but surely the Set-Cookie
header must appear *before* the blank line; that blank line separates the
headers from the response body.
--
Gabriel Genellina
Thanks, that seemed to work.
rod
Also how do I find out if a cookie has expired? I have tried various
methods but to no avail?
Cheers,
rod
En Thu, 07 Feb 2008 10:40:58 -0200, rodmc <us***************@yahoo.co.uk>
escribi�:
Also how do I find out if a cookie has expired? I have tried various
methods but to no avail?
The browser won't send the cookie in that case. The server cannot tell
whether the cookie expired or it never existed, AFAIK.
--
Gabriel Genellina This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: neerolyte |
last post by:
how would i go about setting a cookie in javascript that can be read in
javascript on the next page load, but will NOT be passed to the server?
|
by: HorseGeek |
last post by:
I have three servers: Server1, Server2, and Server3.
There is a login cookie does not expire for SOME users on Server2.
Ironically, the login cookie expires correctly for ALL users on the...
|
by: Robin Day |
last post by:
I have a page that contains some dhtml and uses client side cookies so store
it's current state so that on clicking the "back" button to it the page will
be as the user last saw it.
However,...
|
by: Wysiwyg |
last post by:
After a server created cookie is processed on the client I want it removed,
cleared, or expired in the javascript block but have been unable to do this.
If I set a cookie value in the server code...
|
by: Andre Ranieri |
last post by:
I'm trying to create a login page for customers to log into our corporate
website, our presidents naturally wants the user and password fields to
populate from a cookie so the customer doesn't have...
|
by: HopfZ |
last post by:
Server sends cookie to browser and the browser send the same cookie
back to the server according to Wikipedia.
Do browsers send even javascript-generated cookie to servers?
For example, if I...
|
by: =?Utf-8?B?YzY3NjIyOA==?= |
last post by:
Hi all,
Is there an easier way to handle that? I used Javascript to handle this when
our two domains are hosted on two different servers(on different networks)
and our search engine marketing...
|
by: arijitdas |
last post by:
Hi,
We have an ASP.NET 2.0 web application where we want to share few user
specific data between server and client side code using cookie. We are
seeing a very strange behavior that it does not...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |