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 8394411
In Process

The Archive Base Latest Questions

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

I am trying to stay logged in to a website while I run a

  • 0

I am trying to stay logged in to a website while I run a program continuously. The session eventually times out though.

Here is my test program:

import urllib
import urllib2
import cookielib
import re

url = 'https://www.locationary.com/'

data = urllib.urlencode({"inUserName":"EMAIL", "inUserPass":"PASSWORD"})
jar = cookielib.FileCookieJar("cookies")
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
opener.addheaders.append(('User-agent', 'Mozilla/5.0 (Windows NT 6.1; rv:13.0) Gecko/20100101 Firefox/13.0.1'))
opener.addheaders.append(('Referer', 'http://www.locationary.com/'))
opener.addheaders.append(('Cookie','site_version=REGULAR; JSESSIONID=781FD0C497FB596954BB78B1323215F6'))
request = urllib2.Request("https://www.locationary.com/index.jsp?ACTION_TOKEN=tile_loginBar_jsp$JspView$LoginAction", data)
response = opener.open(request)
page = opener.open(url).read()
print re.findall(r'<title>(.*)</title>', page)
h = response.info().headers
print h

The output is:

['Home Page']
['Server: nginx/1.0.8\r\n', 'Date: Fri, 10 Aug 2012 17:07:47 GMT\r\n', 'Content-Type: text/html;charset=UTF-8\r\n', 'Transfer-Encoding: chunked\r\n', 'Connection: close\r\n', 'Set-Cookie: PSESSIONID=533e2fb9fda008d5d16bfbdc9b9a6afed0e5ac54; Path=/\r\n', 'P3P: CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"\r\n', 'Set-Cookie: PSESSIONID=533e2fb9fda008d5d16bfbdc9b9a6afed0e5ac54; Path=/\r\n']

I experimented…and if I took out the JSESSIONID part of the cookie, my output would be for the home page of the website as if I WASN’T logged in..so it would say “Locationary.com” instead of “Home Page.” When I DO put the JSESSIONID in, everything works, but the server also sets a cookie called PSESSIONID…what does all this mean…and how can I make it so my session doesn’t time out? Do I have to find another JSESSIONID every, say, half an hour?

  • 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-09T20:03:22+00:00Added an answer on June 9, 2026 at 8:03 pm

    Cookies is a mechanism used in order to create the illusion of sessions over a session-less protocol (e.g. http). You can read all about it, just google it (there are many good explanations around).

    If you simply want it to work properly, whenever you get a set-cookie header, keep that value (replacing any old value by the same name), and send it with every request you send. I’d suggest using a dictionary, for robustness.

    Regarding timing out – let the website deal with that, you just follow his orders (i.e. set the cookies 🙂 .

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

Sidebar

Related Questions

I'm writing my Website right now, trying to stay more conservative, but using newer
I m trying to run a cron which involves opening a graphical program and
I'm trying to make text stay in the middle of a resizable DIV. Here's
I am trying to get a footer that will always stay at the bottom
I was trying to have a specific div fade in (left_panel_fade), and stay visible
Trying to build out an exception if move.UserId does not equal currentUserId then Redirect
Trying to figure out how I can do this properly. The print_r looks like
Trying to copy the msdn refernce here doesn't work and gives an error I
Trying to stay completely language agnostic, and avoiding built in methods like Split() and
Im currently using codeigniter to build a messaging system and im trying to stay

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.