Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8343559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:06:03+00:00 2026-06-09T06:06:03+00:00

I am trying to create a small script that is to run in the

  • 0

I am trying to create a small script that is to run in the background and check for incomming new messages on a forum (with phpBB3). As many of the subforums need permissions from a logged in user to be viewed I created a script that would send a post-request to the server to login first.

The script currently gets a successfull login, and is greeted with a welcome message telling me I am logged in. But when I access a new page the script seems to have forgotten that I logged in and my session-cookie is changed.

Here is some small test-code I have created that gives me the error:

import urllib, urllib2, cookielib, re, time

username = "username"
password = "password"
loginsite = "http://www.mydomain.com/ucp.php?mode=login"
ok_tekst = "You have been successfully logged in."        
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
login_data = urllib.urlencode({'username' : username, 'password' : password, 
                                "autologin" : "on", 'login' : 'Login'})

resp = opener.open(loginsite, login_data)
if ok_tekst in resp.read():
    print "Login successfull"
    print "Cookies are:"
    for cookie in cj:
        print cookie

    post_site = "http://www.mydomain.com/"
    ok_tekst = "Logout [ " + username + " ]"
    resp = opener.open(post_site)
    readHTML = resp.read()
    if ok_tekst not in readHTML:
        print ""
        print "Unsuccessfull, I am now logged out?!"
        print "Cookies are now:"
        for cookie in cj:
            print cookie

This produces the following output that also shows the value of the different cookies:

>> python test.py
Login successfull
Cookies are:
<Cookie phpbb3_pwsle_k=b3fe944b89bfbce2 for .mydomain.com/>
<Cookie phpbb3_pwsle_sid=318b3ace3d52409fb5e1eef87433fbdb for .mydomain.com/>
<Cookie phpbb3_pwsle_u=419 for .mydomain.com/>

Unsuccessfull, I am now logged out?!
Cookies are now:
<Cookie phpbb3_pwsle_k= for .mydomain.com/>
<Cookie phpbb3_pwsle_sid=719520cd3a16526d6da4fa2fbdfe40f4 for .mydomain.com/>
<Cookie phpbb3_pwsle_u=1 for .mydomain.com/>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T06:06:05+00:00Added an answer on June 9, 2026 at 6:06 am

    Okey, so I solved the problem my self now – and it seemed the forum I was running had some brower-protection enabled that would cancel any sessions if I visited with a USER-AGENT (in http-header) set to Python/URLLIB. By changing the header to pretend I was google-chrome fixed my problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a shell script that shall convert certain Files according to
I am trying to create a small web app that will allow users to
I am new with MVC I am trying to create a small product form
I have a small program that I'm trying to create to get ip addresses
I'm trying to create a small web app that is used to remove items
I'm trying to create a small form that submits a form and passes a
I'm trying to create a small Javascript framework that I can use in my
I'm new to flex and actionscript. I'm trying to create a small flex app
I'm trying to create a script that will download a dynamically built Initializr zip
I'm trying to create a small slider where jquery UI Scale brings out and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.