webpy中auto_application的cookie共享问题
妙音
posted @ 2013年11月16日 09:27
in webpy
, 2708 阅读
在webpy中使用auto_application划分网站的url结构,会发现是个很好用的东西。
使用过程中却发现每个auto_application默认有自己单独的cookie。
范例
#encoding=utf-8 import web appA = web.auto_application() appB = web.auto_application() urls = ( '/save', appA, '/get', appB ) class SaveName(appA.page): path = '/?' def GET(self): web.setcookie("name", "wyq", expires=24 * 60 * 60) return web.cookies().get("age") class GetName(appB.page): path = '/?' def GET(self): return web.cookies().get("name") app = web.application(urls, globals()) if __name__ == '__main__': web.config.debug = True app.run() #print app.request("/save").data #print app.request("/get").data
上面代码,生成两个auto_application appA与appB。
appA处理所有以/save开头的url请求,appB处理所有以/get开头的url请求。
appA = web.auto_application() appB = web.auto_application()
发送http://0.0.0.0:8080/save请求,将name信息保存在cookie中。
web.setcookie("name", "wyq", expires=24 * 60 * 60)
发送http://0.0.0.0:8080/get请求,获取name值。
预想是返回name值,却发现结果为空。什么原因呢?
观察下面从chrome中取到的截图。
/save请求

注意上面的Set-Cookie,多了个path=/save/。原来在application中保存cookies时,会设置cookies的path属性。
cookie的path属性,用于限制cookie的访问域,只有此域下的请求才能取到此cookie信息。
换句话说只有url以/save/开头的请求才能,取到此cookie的信息。
上面appA属于/save/域下的,appB属于/get/域下的。它们属于不同的域,所以appB访问不到appA中的cookie。
如何解决呢?办法就是在设置cookie时添加path="/"的属性,即可解决。
web.setcookie("name", "wyq", expires=24 * 60 * 60, path="/")
2020年12月14日 16:28
nice bLog! its interesting. thank you for sharing.... soap2day.world
2020年12月27日 17:06
Great knowledge, do anyone mind merely reference back to it 먹튀검증업체
2021年1月07日 15:37
ดูบอลออนไลน์ ดูบอลสด ต้องดูบอลรวย อัพเดทสดใหม่ทุกวัน พร้อมทั้งมี ไฮไลท์บอล โปรแกรมบอล ผลบอล ราคาบอล หรือ ข่าวสารกีฬา และ ข่าวดังข่าวกระแสอีกมากมาย <a href="http://ดูบอลรวย.com/">ดูบอลออนไลน์</a>
2021年1月07日 18:42
Apply Fastag ICICI Bank is a brand name owned by Indian Highways Management Company Ltd. (IHMCL) which carries out electronic tolling and other ancillary projects of National Highway Authorities of India (NHAI). This Radio Frequency Identification Device (RFID) tag is affixed on the windscreen of the vehicle.
2021年1月07日 21:29
The UAN or Unifiedportal.epfindia.gov.in Account Number is an umbrella number for the multiple Employee Provident Fund Numbers or Member IDs allotted to an individual by various employers. The idea is to link these multiple employee PF Number of a person to a single 12-digit Universal Account Number. This means the account number remains unchanged across organizations since it is linked to a particular person.
2021年1月07日 22:18
Your post is very helpful to get some effective tips to reduce weight properly. You have shared various nice photos of the same. I would like to thank you for sharing these tips. Surely I will try this at home. Keep updating more simple tips like this. ดูหนังโป๊ออนไลน์
2021年1月08日 14:46
To avail the Transfer claim or Advance Withdrawal Claim or Permanent Withdrawal Claim facilities, updating KYC is a mandatory requirement. Once the KYC details are submitted by the employees, the employer has to verify and approve the KYC details using the Digital Signature registered on the Employees Provident Fund Establishment Portal i.e Unifiedportal-emp.epfindia.gov.in.
2021年1月12日 18:57
Very good points you wrote here..Great stuff...I think you've made some truly interesting points.Keep up the good work. 먹튀검증
2021年1月14日 14:49
Fabulous post, you have denoted out some fantastic points, I likewise think this s a very wonderful website. I will visit again for more quality contents and also, recommend this site to all. Thanks. best canadian online casino
2021年1月19日 18:57
I love visiting sites in my free time. I have visited many sites but did not find any site more efficient than yours. Thanks for the nudge! สมัคร slot เครดิตฟรี แค่ยืนยันตน
2021年1月23日 20:00
Regular visits listed here are the easiest method to appreciate your energy, which is why why I am going to the website everyday, searching for new, interesting info. Many, thank you 먹튀검증
2021年1月23日 21:00
At We Walk Together L LC, we are dedicated to providing patients with the best possible care. We at WE WALK TOGETHER LLC are focused on helping you. Sport physical
2021年1月27日 21:06
This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. 198.168.0.1 User Name
2021年1月28日 20:43
Wow, this is really interesting reading. I am glad I found this and got to read it. Great job on this content. I like it. 審計 報告
2021年1月30日 02:37
Extraordinary things you've generally imparted to us. Simply continue written work this sort of posts.The time which was squandered in going for educational cost now it can be utilized for studies.Thanks tik tok takipçi satın al
2021年2月02日 23:17
HayatMed Clinic Provide High Quality convenient and affordable hair transplant surgery in Turkey, Our doctors have years of experience. Please visit our website for free consultation.
2021年2月03日 20:34
The first phase the preparation should, theoretically, be uninfluenced by the intended intensity and duration of the sound which is subsequently produced. In fact, however, so quickly are the three phases accomplished that the pianist rarely has capacity to think, in performance, of each phase separately. เบ้นซ์
2021年2月04日 11:57
Allahabad Bank started its operation in the year 1865 and is headquartered in Kolkata. The bank offers a wide range of banking products and financial services to its customers like debit cards, credit cards, mobile banking, netbanking and more. <a href='https://onlinenet-banking.in/allahabad-bank-online-net-banking-registration/'>Allahabad Bank online banking</a> allows its users to do banking transactions such as transferring money, paying a bill, checking balance or setting up a regular payment on bank etc.
2021年2月04日 11:58
After the successful generation of password, the users can carry out a host of allahabad bank online banking services via the net banking portal including balance check, account statement, funds transfer and more
2021年2月05日 14:10
I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement the concept. Thank you for the post. remote work confidence building
2021年2月08日 03:44
A lot of people having an incorrect image about the cash advance loans or sometimes refer it as bad credit payday loans. gator fencing
2021年2月09日 01:27
Your post has those facts which are not accessible from anywhere else. It’s my humble request to u please keep writing such remarkable articles hotel amenities
2021年2月09日 15:18
I truly value this superb post that you have accommodated us. I guarantee this would be helpful for a large portion of the general population. LegalTech
2021年2月09日 19:01
I was impressed with the site that you created, so memotipasi many people to be more advanced, there also kunjugi me, as a comparison Small Claims Portal
2021年2月10日 21:48
You have a real talent for writing unique content. I like how you think and the way you express your views in this article. I am impressed by your writing style a lot. Thanks for making my experience more beautiful. NAPSRX
2021年2月11日 13:15
First You got a great blog .I will be interested in more similar topics. i see you got really very useful topics, i will be always checking your blog thanks. body contouring
2021年2月11日 14:29
Thanks for the tips guys. They were all great. I have been having issues with being fat both mentally and physically. Thanks to you guys i have been showing improvements. Do post more. Magento eCommerce agency in London England
2021年2月17日 14:51
Thanks for an interesting blog. What else may I get that sort of info written in such a perfect approach? I have an undertaking that I am just now operating on, and I have been on the lookout for such info. allbet
2021年2月17日 20:12
Our credit repair services work to fix past credit mistakes and verify credit report accuracy. Talk to a credit repair expert today! 꽁머니 1만
2021年2月18日 14:52
Nice to be visiting your blog again, it has been months for me. Well this article that i've been waited for so long. I need this article to complete my assignment in the college, and it has same topic with your article. Thanks, great share.
2021年2月22日 15:07
Thanks for the blog filled with so many information. Stopping by your blog helped me to get what I was looking for. Now my task has become as easy as ABC. 토토
2021年2月22日 22:06
UP Board students will be able to collect their UP Board 10th Admit Card 2021 from their respective schools in January. The State Board will be releasing the UP Board 10th Admit Card 2021 on its official website for the private students. They will be able to download the UP Board Admit Card for Class 10th using their username and password. The admit card mentions the student’s name, roll number, exam dates, exam centre details, etc. UPMSP 10th Admit Card 2021
2021年2月23日 18:12
I'm constantly searching on the internet for posts that will help me. Too much is clearly to learn about this. I believe you created good quality items in Functions also. Keep working, congrats! virtual office Los Angeles
2021年2月26日 15:13
If you want to organize a family photo shoot, please don’t hesitate to contact me at any time. Family photographer London
2021年2月26日 21:35
Play Online Rummy Card and Cricket Games on India’s Number 1 & Best Online Game Website. Get up to ₹1000 daily bonus. Enjoy with 24Club now cricket score
2021年2月27日 15:21
NEVER PAY UP-FRONT FEES.USE ESCROW TO EXIT YOUR TIMESHARE timeshare freedom group
2021年2月28日 02:59
Get the latest breaking and in-depth news,headlines,photos and videos on radical Islamic terrorist groups. Whether you are Muslim or not your input is vital.For any information,ideas,opinions contact us or write us @ shaniathura@gmail.com International Politics News
2021年3月05日 01:20
In addition, there are Para-Okazino, Coin Casino, Sands Casino, Okada Casino, Merit Casino, First Casino, Duzon Casino, and SM Casino. https://lampcasino
2021年3月07日 00:01
Hi, welcome to our webpage, please be patient as we are updating daily. ipe
2021年3月07日 01:03
Share your files directly using email or you can share using a secure link Transfer Large File
2021年3月08日 02:36
Pool Plaster Inc. | quartz plaster | Pool Renovation Services Boston quartzscape
2021年3月15日 01:46
You guardians do an astounding web diary, and have some unfathomable substance. Continue doing extraordinary. Removal company near me
2021年3月19日 01:34
Write.law is a game changer for training lawyers and law students alike. The breadth and depth of the skills you can improve—from legal tech to legal writing—are impressive, as are its seamless platform and interactive lessons. I highly recommend Write.law for everyone. Lawyer Courses and Classes
2021年3月19日 17:18
The Lampliter | Indianapolis outdoor lighting, Installation & Maintenance in Central IN, our Outdoor Lighting Professionals.
2021年3月23日 20:51
Get free Powerful Learning English Lessons, We share great materials and useful articles, tutorials and videos on Gr8English.com to help individuals who are learning English. Improve Your English With Online Video Lessons. Please visit our website for a unique way to learn english. Thank You.
2021年3月24日 02:16
Buy tadalafil on Access Doctor - Online Doctor & Pharmacy UK | Free Delivery | Access Doctor including its uses, side effects and safety, interactions, pictures, warnings and user ratings.
2021年3月25日 02:23
crime scene cleanup missouri after death cleaning help in cities in Missouri Get quotes for crime scene cleanup missouri or blood cleanup suicide cleanup throughout Missouri for free.
2021年3月29日 19:42
Let Paillian help you find the perfect custom gift! We offer free consultations for specific custom items Please use our contact page We cant wait to make you something! Buy Custom Items Online Contact us for more details.
2021年4月08日 14:12
Easily Locate Shopping Outlet Mall near Me as in Your Area from the Most Reputable Online Directory Satisfy Your Shopping Needs Fast with Malls Near Me, Locate Shopping & Outlet Malls Near Me Fast!
2021年5月18日 04:42
David and Jess are your Atlanta Photographers The professional Atlanta photographers for all of your Atlanta photography needs 850 512 6275 Portraits, Headshots Atlanta, Online dating pictures and more Serving Atlanta and surrounding areas.
2021年5月20日 21:22
Invest in cyprus permanent residency program and establish a Mediterranean home away from home Requirements Benefits. Cyprus Permanent Residence Program - By Investment. Cyprus Residency Program offers the opportunity for those acquiring property to establish a Mediterranean home and becoming resident in Cyprus. Please visit our website for more details. Thank You.
2021年5月25日 19:57
Hi Looking for Custom bobbleheads cheap? Make Your Own Personalized bobblehead- Dolls Make your own bobblehead Made From Your Photos 50 148 with Amazing Likeness and Fast Turnaround Time, Offer Gift Box and Card, 100 Satisfactios. At Bbobbler, we use high-quality material for designing the bobbleheads.
2021年6月17日 22:15
Most of the time I don’t make comments on websites, but I'd like to say that this article really forced me to do so. Really nice post! slope.io
2021年6月19日 21:01
Very informative post! There is a lot of information here that can help any business get started with a successful social networking campaign. Face mask
2021年7月13日 21:52
You have performed a great job on this article. It’s very precise and highly qualitative. You have even managed to make it readable and easy to read. You have some real writing talent. Thank you so much. 토토사이트
2022年3月09日 13:09
The Government of Haryana State has designed the School Management Information System for the welfare of Schools in the state. The school staff, teachers, and students have got direct access to the portal through which most of the services easily processed. saksham login The MIS Portal also referred to as Saksham Haryana Education Portal which is a one-stop website for every need of Schools in Haryana. The New aspirants can utilize this option to apply for their selected school form online by submitting the application form.
2022年4月20日 00:36
As a seller of legal steroids, you can buy Crazy Bulk products, explore stacks and finally get the body you’ve always wanted
2022年4月22日 05:22
You completed certain reliable points there. I did a search on the subject and found nearly all persons will agree with your blog.
2022年5月08日 03:33
I have express a few of the articles on your website now, and I really like your style of blogging. I added it to my favorite’s blog site list and will be checking back soon… Buy marijuana online
2022年5月14日 06:15
Glad to chat your blog, I seem to be forward to more reliable articles and I think we all wish to thank so many good articles, blog to share with us. fixed deposit
2022年6月08日 05:06
I see some amazingly important and kept up to length of your strength searching for in your on the site สูตรบาคาร่า ใช้ได้จริง
2022年8月01日 07:05
I have a mission that I’m just now working on, and I have been at the look out for such information heels
2022年8月09日 15:31
Link farms are websites which exist solely to collect numerous links from web directories. The more links they have, the higher their site will climb in the rankings of search engine results. deep web
2022年8月09日 22:33
GHANA News ONLINE is a content curation and syndication website to offer news stories across the length and breadth of Ghana. ghananewsonline
2022年8月26日 01:42
ОТДЫХ ВСЕЙ СЕМЬЕЙ Особое внимание мы уделили детским программам, чтобы Вы могли полноценно расслабиться и насладиться отпуском. Коса Беляус
2022年9月02日 06:28
Cool stuff you have and you keep overhaul every one of us breaking news
2022年9月06日 20:10
I have express a few of the articles on your website now, and I really like your style of blogging. I added it to my favorite’s blog site list and will be checking back soon… naked url