Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
1
Question by J3-Gaming · Nov 22, 2012 at 09:47 PM · wwwwwwformheaderscookies

PHPSESSID with Unity

Hello everyone, I'm looking for some expert advice here.

Currently I have a working WWW call to login to a website

 public IEnumerator Login()
 {
     WWW www;
     WWWForm form = new WWWForm();
         
     form.AddField("player", username);
     form.AddField("password", password);
         
     www = new WWW(WEBSITE + "/authenticate.php", form);
     yield return www;
     ProcessHeaders(www.responseHeaders);
     isLoggedIn = true;
         
     ScanHTML(www.text);
 }

I already expected that if I wanted to visit another page (meaning another WWW call) via my app and logged in, I would have to store and send some session cookies.

The problem is that the website appears to rely on the 'PHPSESSID' cookie to stay logged in, which I cannot find in any WWW return variables (like responseHeaders).

Any ideas? Ill be checking back frequently if more information needs to be posted.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Bunny83 · Nov 23, 2012 at 12:31 AM

Usually the resposeHeaders should contain a Set-Cookie header. One problem could be that the website wants to set multiple cookies at once. In this case it's not possible to get all cookies because Unity's WWW class uses a Hashtable to store the response headers. By definition a HTTP response can include multiple Set-Cookie headers, but the Hashtable merge them into one and only the last one will survive.

If that's the case, you can't use WWW to get that cookie information. Try to use a C# class (WebRequest, HttpClient, ...) to request the website.

I've posted a feedback long time ago, but it seems no one cares :D

edit
You can use wireshark to check if and how many Set-Cookie headers the response contains.

Comment
Add comment · Show 2 · Share
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
avatar image J3-Gaming · Nov 23, 2012 at 02:10 AM 0
Share

That explains why I only get 1 Set-Cookie response. Thanks.

avatar image J3-Gaming · Nov 27, 2012 at 07:06 AM 0
Share

error CS0246: The type or namespace name `async' could not be found. Are you missing a using directive or an assembly reference?

It appears we cannot use HttpClient async like we do for IEnumerator. Any other ideas or example code?

avatar image
0

Answer by Graham-Dunnett · Nov 22, 2012 at 10:47 PM

PHP sessions can use a URL parameter. Use that instead of cookies.

Comment
Add comment · Show 1 · Share
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
avatar image J3-Gaming · Nov 23, 2012 at 12:04 AM 0
Share

How would that work if the website relies on cookies? I do not own the website and do not have access to edit it.

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.

Follow this Question

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do I add a header and a file at the web request at the same time? 0 Answers

Posting raw XML data to web - no parameter name 2 Answers

Present cookie data in WWWForm? 2 Answers

HttpWebRequest No longer working? 0 Answers

"SecurityException: No valid crossdomain" even though the webplayer didn't even try to get the crossdomain policy request. 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