• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by sugitashannon · Apr 12, 2015 at 12:46 PM · cookie

How to set cookie to GET method?

Hi there

I want to set cookie for Django.

But, I cant set well.

it is GET. not POST.

I create header this code.

define:

     public Hashtable hsHeader;

in the Start methot.

     void Start ()
     {
         this.hsHeader = new Hashtable();

create cookie for header:

                 Dictionary<string,string> headers = www.responseHeaders;
                 foreach (KeyValuePair<string,string> kvPair in headers)
                 {
                     // key: SET-COOKIE
                     // value: csrftoken=1ekAyo4iiK359qyLwTUlekzxoCEMFoRV; expires=Sat, 09-Apr-2016 00:08:18 GMT; Max-Age=31449600; Path=/
                     if (kvPair.Key.ToLower ().Equals ("set-cookie"))
                     {
                         string stHeader = "";
                         string stJoint = "";
                         string[] astCookie = kvPair.Value.Split (
                             new string[] {"; "}, System.StringSplitOptions.None);
 
                         foreach (string stCookie in astCookie)
                         {
                             //if (!stCookie.Substring (0, 5).Equals ("path="))
                             if (!stCookie.Substring (0, 5).ToLower ().Equals ("path="))
                             {
                                 stHeader += stJoint + stCookie;
                                 stJoint = "; ";
                             }
                         }
 
                         if (stHeader.Length > 0)
                         {
                             //  csrftoken=AisAwFCgmgMGRwC6y1OXPu2brzwwMdGz; expires=Sat, 09-Apr-2016 00:49:13 GMT; Max-Age=31449600
                             this.hsHeader ["Cookie"] = stHeader;
                             //this.hsHeader ["Cookie"] = stHeader + ";";
                             //this.hsHeader ["Content-Type"] = "application/json";
                             //this.hsHeader ["Cookie"] = kvPair.Value;
                         }
                         else
                         {
                             this.hsHeader.Clear ();
                         }
                     }
                 }


And, I send date as GET this code

 WWW www = new WWW (openURL, null, this.hsHeader);

it is GET. so I set null.

in the first access. I success.

But, later server side Django said the error.

 Traceback (most recent call last):
   File "/usr/local/Python2.7.5/lib/python2.7/SocketServer.py", line 593, in process_request_thread
     self.finish_request(request, client_address)
   File "/usr/local/Python2.7.5/lib/python2.7/SocketServer.py", line 334, in finish_request
     self.RequestHandlerClass(request, client_address, self)
   File "/usr/local/Python2.7.5/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 126, in __init__
     super(WSGIRequestHandler, self).__init__(*args, **kwargs)
   File "/usr/local/Python2.7.5/lib/python2.7/SocketServer.py", line 649, in __init__
     self.handle()
   File "/usr/local/Python2.7.5/lib/python2.7/wsgiref/simple_server.py", line 124, in handle
     handler.run(self.server.get_app())
   File "/usr/local/Python2.7.5/lib/python2.7/wsgiref/handlers.py", line 92, in run
     self.close()
   File "/usr/local/Python2.7.5/lib/python2.7/wsgiref/simple_server.py", line 33, in close
     self.status.split(' ',1)[0], self.bytes_sent
 AttributeError: 'NoneType' object has no attribute 'split'


Could you tell me how to fix it?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Classic: The prefab you want to instantiate is null. -.- 1 Answer

Shader on built-in render pipeline in 2019.3.0f6 not receiving shadows when light has cookie 0 Answers

How do I create a moving cookie texture for a directional light? 2 Answers

How to set LightType for Light Cookie in TextureImporter script? 1 Answer

Flashlight Cookie Not Displaying 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges