Hello,
I wanted to solve coding levels with Java. The problem is that when I connect with HttpsUrlConnection class I get “guest” response from the web as I’m missing cookies. I tried to set them with setRequestProperty method but with no luck, I copied all my cookies but I guess PHPSESSID is actually the only that matters. How can I easily set the cookies correctly?
My code:
```import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
public class Networking101 {
public static void main(String[] args) throws Exception {
URL strona = new URL("https://www.hackthis.co.uk");
HttpsURLConnection sslstrona = (HttpsURLConnection)strona.openConnection();
sslstrona.setRequestProperty("Cookie", "PHPSESSID=SOMETHING :)");
sslstrona.connect();
BufferedReader czytasz = new BufferedReader(new InputStreamReader(sslstrona.getInputStream()));
String zawartosc;
while ((zawartosc=czytasz.readLine())!=null) {
System.out.println(zawartosc);
}
czytasz.close();
}
}```