473,698 Members | 2,022 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cookie

hi!

i am printing a simple cookie, but instead of printing
um=name:blah&ac cess:admin&exp: 2312390.909

its printing
um="name:blah&a ccess:admin&exp :2312390.909"

why the quotes?

i am creating the cookie as follows:
data = "user:" + username + "&access:" + access + "&expiry:" + str(expTime)
cookie_digest = hmac.new(key, data).digest()
cookie = Cookie.SimpleCo okie()
cookie_data = data + "&digest:" + cookie_digest
cookie["um_cookie"] = cookie_data
cookie["um_cookie"]["path"] = "/~abrar1/hons/interface/admin/"
print cookie

thanks
cheers

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
Jul 18 '05 #1
6 2193
Ajay <ab******@mail. usyd.edu.au> writes:
hi!

i am printing a simple cookie, but instead of printing
um=name:blah&ac cess:admin&exp: 2312390.909

its printing
um="name:blah&a ccess:admin&exp :2312390.909"

why the quotes?


Why not?

I don't see how they'd cause any harm.
John
Jul 18 '05 #2
they dont cause any harm, except for a an extra statement removing those
quotes when i read the cookie, parse it and authenticate the session.
the question is - is that normal cookie behaviour?
cookie["test"]="blah"
print cookie

prints test=blah and not test="blah"
so why the quotes when i do the same thing, but use a variable instead of a
string literal?

cheers
Quoting "John J. Lee" <jj*@pobox.com> :
Ajay <ab******@mail. usyd.edu.au> writes:
hi!

i am printing a simple cookie, but instead of printing
um=name:blah&ac cess:admin&exp: 2312390.909

its printing
um="name:blah&a ccess:admin&exp :2312390.909"

why the quotes?


Why not?

I don't see how they'd cause any harm.
John
--
http://mail.python.org/mailman/listinfo/python-list

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
Jul 18 '05 #3
Ajay <ab******@mail. usyd.edu.au> writes:
Quoting "John J. Lee" <jj*@pobox.com> :
Ajay <ab******@mail. usyd.edu.au> writes: [...]
i am printing a simple cookie, but instead of printing
um=name:blah&ac cess:admin&exp: 2312390.909

its printing
um="name:blah&a ccess:admin&exp :2312390.909"

why the quotes?


Why not?

I don't see how they'd cause any harm.

they dont cause any harm, except for a an extra statement removing those
quotes when i read the cookie, parse it and authenticate the session.
the question is - is that normal cookie behaviour?
cookie["test"]="blah"
print cookie

prints test=blah and not test="blah"
so why the quotes when i do the same thing, but use a variable instead of a
string literal?


You've lost me, but on the basis of a very quick test, the Cookie
module preserves quotes across the parse->output cycle:
import Cookie
c = Cookie.SimpleCo okie()
c.load('foo=bar ')
print c Set-Cookie: foo=bar; c.load('foo="ba r"')
print c Set-Cookie: foo="bar";


That seems sensible behaviour to me, since quotes around cookie values
are significant for Netscape cookies (ie. regular, vanilla, internet
cookies).

I can categorically state that using a variable name instead of a
string literal will make no difference whatsoever. I think you're
actually confused about Python syntax rather than the workings of the
Cookie module. Try reading the Python language tutorial at
www.python.org.
John
Jul 18 '05 #4

Quoting "John J. Lee" <jj*@pobox.com> :
Ajay <ab******@mail. usyd.edu.au> writes:
Quoting "John J. Lee" <jj*@pobox.com> :
Ajay <ab******@mail. usyd.edu.au> writes: [...] > i am printing a simple cookie, but instead of printing
> um=name:blah&ac cess:admin&exp: 2312390.909
>
> its printing
> um="name:blah&a ccess:admin&exp :2312390.909"
>
> why the quotes?

Why not?

I don't see how they'd cause any harm.
they dont cause any harm, except for a an extra statement removing

those
quotes when i read the cookie, parse it and authenticate the session.
the question is - is that normal cookie behaviour?
cookie["test"]="blah"
print cookie

prints test=blah and not test="blah"
so why the quotes when i do the same thing, but use a variable instead

of a
string literal?


You've lost me, but on the basis of a very quick test, the Cookie
module preserves quotes across the parse->output cycle:
import Cookie
c = Cookie.SimpleCo okie()
c.load('foo=bar ')
print c Set-Cookie: foo=bar; c.load('foo="ba r"')
print c Set-Cookie: foo="bar";
That seems sensible behaviour to me, since quotes around cookie values
are significant for Netscape cookies (ie. regular, vanilla, internet
cookies).

I can categorically state that using a variable name instead of a
string literal will make no difference whatsoever.


i believe you. i didn't think it would make a difference. and i agree that
the Cookie module preserves quotes across the parse->output cycle
my question is
import Cookie
c = Cookie.SimpleCo okie()
c["test"]= "blah"
print c Set-Cookie: test=blah; c["test"] = "blah" + "testing"
print c Set-Cookie: test=blahtestin g; str = "testing blah"
c["test"] = str
print c

Set-Cookie: test="testing blah";

why does the final print statement have the quotes. Note i haven't put
str='"testing blah"'. if i had done that i would understand the quotes
there.
I think you're
actually confused about Python syntax rather than the workings of the
Cookie module. Try reading the Python language tutorial at
www.python.org.
yes i should probably read that :)
it doesn't though mention anything about the above behaviour

cheers

John
--
http://mail.python.org/mailman/listinfo/python-list

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
Jul 18 '05 #5
Ajay <ab******@mail. usyd.edu.au> writes:
[...]
i believe you. i didn't think it would make a difference. and i agree that
the Cookie module preserves quotes across the parse->output cycle
my question is
import Cookie
c = Cookie.SimpleCo okie()
c["test"]= "blah"
print c Set-Cookie: test=blah; c["test"] = "blah" + "testing"
print c Set-Cookie: test=blahtestin g; str = "testing blah"
c["test"] = str
print c Set-Cookie: test="testing blah";

why does the final print statement have the quotes. Note i haven't put
str='"testing blah"'. if i had done that i would understand the quotes
there.


Does the following help?

Python 2.4a2 (#5, Aug 5 2004, 22:07:01)
[GCC 2.95.4 20011002 (Debian prerelease)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.
import Cookie
c = Cookie.SimpleCo okie()
c["test"] = "testingbla h"
print c Set-Cookie: test=testingbla h; c["test"] = "testing blah"
print c Set-Cookie: test="testing blah";

John
Jul 18 '05 #6
In <ma************ *************** ***********@pyt hon.org>, Ajay wrote:
my question is
import Cookie
c = Cookie.SimpleCo okie()
c["test"]= "blah"
print c Set-Cookie: test=blah; c["test"] = "blah" + "testing"
print c Set-Cookie: test=blahtestin g; str = "testing blah"
c["test"] = str
print c Set-Cookie: test="testing blah";

why does the final print statement have the quotes. Note i haven't put
str='"testing blah"'. if i had done that i would understand the quotes
there.


It's no difference if you bind the string to a name or assign it directly,
it's the contents of the string:
import Cookie
c = Cookie.SimpleCo okie()
c["test"] = "spaceless"
print c Set-Cookie: test=spaceless; c["test"] = "not spaceless"
print c

Set-Cookie: test="not spaceless";

Ciao,
Marc 'BlackJack' Rintsch
Jul 18 '05 #7

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

Similar topics

4
5290
by: Shannon Jacobs | last post by:
I'm doing some trivial surveys, and I want to know if the same user answers twice. Can't really know that, but at least I thought I could check for the same browser/computer combination by using a cookie. Here is the code I have now. In the header, I have the following: <SCRIPT language="JavaScript"> var cookieStatus; if (document.cookie.length > 0) { cookieStatus = 'Cookie exists with value ' + document.cookie; } else {
12
17998
by: chrism | last post by:
Hello, I have a pop-up window that I would like to appear in front of the browser home page when a user opens IE. Problem is, I'd like it to never appear again if the user navigates back to the home page during their time using the browser. However, if the user closes the browser, then reopens, the pop-up should appear again. (you may have guessed that this will be used for public access pc's.) I want to try as best I can to catch...
5
3312
by: brettr | last post by:
When I reference document.cookie, there is a long string of key=value; pairs listed. I may have 100 hundred cookies on my hard drive. However, most only have one key=value pair. Does the document.cookie variable combine all cookie key=value pairs? All of the examples I've seen discuss referencing a specific cookie. I don't see how this is done. Cookies are usually named by the domain. If I want to reference a specific cookie, do I...
4
3814
by: socialism001 | last post by:
I'm trying to store a value in a cookie but its not working. Can anyone see what I might be doing wrong. Thanks, Chris ~~~~~~~~~~~~~~~~~~ <script language="javascript"> if(document.cookie.indexOf("beenHere1=true")!=-1) else
9
4496
by: Marco Krechting | last post by:
Hi All, I have a page with a list of hyperlinks. I want to save information in a cookie about the fact that I entered an hyperlink or not. When I click one of the hyperlinks I want this stored in a cookie and a small bullit shown in front of the hyperlink, so when I reload the page I can immediately see which hyperlinks I already visited that day.
3
11117
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 behind and don't use a domain then I can not change or remove that cookie's value on the client. If I subsequently create the cookie again in the codebehind then I actually end up with TWO cookies with the same name in the response. The cookie...
1
6709
by: CR1 | last post by:
I found a great cookie script below, but don't know how to make it also pass the values sent to the cookie, to a querystring as well for tracking purposes. Can anyone help? If there was a way to simply pass the values in a cookie to the querystring that would be even easier, but from what I've been able to tell, cookie values can't be passed to a querystring. I'm sure the answer will help alot of others who are using this script, and would...
6
2697
by: kelvlam | last post by:
Hello all, I'm still a bit new with JavaScript, and I hope the guru here can shed some light for me. It's regarding handling cookie and the case-sensitive nature of JavaScript itself. My problem is how do I handle the "path" parameter in cookie. First, the sequence start at http://www.testServer1.com/TestApp/page1.htm, and a cookie is set at
2
2849
by: kelly.pearson | last post by:
Is this a bug? I am trying to write a cookie that can be accessed by various .Net applications on our domain. However, whenever I add the domain property to the cookie, no errors get thrown but the cookie doesn't get written. I am trying this from my localhost using vs2003, .net framework 1.1, windows xp prof. Sample code I am testing with is below. Public Class WebForm1 Inherits System.Web.UI.Page
5
3161
by: cbhoem | last post by:
Hi - I am trying my hand at python cookies. I'm confused about a few things though. Do the python cookies get written to a cookies text file? I have simple code below -- I see the cookie in my HTTP header but do not get anything in the cookie text file. I'm working on linux. print "Content-type: text/html" cookie = Cookie.SimpleCookie()
0
8674
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...
0
8603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
5860
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
4369
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...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2329
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
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.