变量范围(未设置)? 【JAVA]

时间:2015-12-14 09:30:17

标签: java cookies

所以我试图存储一个连接的cookie,然后再重新使用它们。然而,似乎当我设置cookie然后调用下一个函数时,它们似乎消失了。

Main.java

Bumper thread = Threads.get(x); //looping through a list
thread.login();
thread.bump(); 

Bumper.java

public class Bumper {
    CookieStore cookies;

    public void setCookies(CookieStore cookie){
        this.cookies = cookie;
    }

    public CookieStore getCookyz(){
        return this.cookies;
    }

    public void login() throws Exception {

    HttpClient httpClient = new HttpClient();
    httpClient.setFollowRedirects(false);
    httpClient.start();

    Fields fieldForm = new Fields();

    fieldForm.add("do","login");
    fieldForm.add("url","");
    fieldForm.add("vb_login_md5password", this.password);
    fieldForm.add("vb_login_md5password_utf", this.password);
    fieldForm.add("s", "");
    fieldForm.add("vb_login_username", this.username);
    fieldForm.add("vb_login_password", "");

    FormContentProvider form = new FormContentProvider(fieldForm);


    ContentResponse response = httpClient.POST("http://www.sythe.org/login.php?do=login")
            .agent("Mozilla/5.0")
            .content(form)
            .send();

          this.setCookies(httpClient.getCookieStore());
            for(HttpCookie c : this.getCookyz().getCookies())
                System.out.println(c.toString());
          System.out.println("Logged In");
    }

    public void bump() throws Exception {           
            for(HttpCookie c : this.getCookyz().getCookies())
                System.out.println(c.toString());
            System.out.println("Bumped"); 
    }
}

什么是输出

  __cfduid=d059a09bfabef0a5bae2e318891450085011
    bblastvisit=14505011
    bblastactivity=0
    bbsessionhash=7b6c57cd6a62a20e144cd
    Logged In (The termination of the Login function)
    Bumped (The termination of the Bump function)

地球上的饼干从一个功能到另一个功能?他们为什么不保留?它在一个函数(登录)中打印cookie,但在下一个(碰撞)中似乎不存在。

我尝试在" cookies"上添加不同的标识符。变数无济于事。有什么想法吗?

0 个答案:

没有答案