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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:04:28+00:00 2026-06-04T01:04:28+00:00

class … self.response.headers.add_header(‘Set-Cookie’,’user_id = %s’% id_and_hash) self.redirect(/app/login) class ThanksHandler(webapp2.RequestHandler): def get(self): if ‘user_id’ in

  • 0
class ...
self.response.headers.add_header('Set-Cookie','user_id = %s'% id_and_hash)
        self.redirect("/app/login")

class ThanksHandler(webapp2.RequestHandler):
    def get(self):
        if 'user_id' in self.request.cookies:
            self.response.out.write('user_id')
        else:
            self.response.out.write("wrong") // what i am getting

and i have this cookie (I saw in a manager of cookies)

name: user_id
content: 30|a9bdc98e952c0e787aaf0e5466809eea71635d38446d30a9f71f2d15e99fa701

well, basically the problem is that i can’t retrieve the cookie that has been initialized. Any reason for that?

  • 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-04T01:04:30+00:00Added an answer on June 4, 2026 at 1:04 am

    When setting the cookie directly using the "Set-Cookie" HTTP-header you have to also take care of the cookie-attributes (depending on how you want to use the cookie).

    In this case you set the cookie for example in the path /app/auth and then redirect to /app/login. If you don’t explicit specify the cookie-path the browser assumes /app/auth and therefore the cookie is not sent when requesting /app/login. This behaviour is specified in the RFC 6265 (this is more recent than the one I cited in my comment but now the exact algorithm is included in section 5.1.4).

    To set the path (or any other cookie-attribute) you can append a list of semicolon-delimited name=value pairs. In this case you want to set the path to / (it could be something different like /app):

    self.response.headers.add_header('Set-Cookie','user_id=%s; Path=/'% id_and_hash)
    

    Of course most libraries/frameworks already provide a wrapper for the "Set-Cookie" header. In the case of "webapp2" you can set the cookie with response.set_cookie:

    self.response.set_cookie('user_id', id_and_hash)
    

    It’s automatically setting the path to / so you don’t have to worry about it (it does escape the values properly too).

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

Sidebar

Related Questions

class Achievement(MyBaseModel): parent_achievement = models.ForeignKey('self', blank=True, null=True, help_text=An achievement that must be done before
class ITestType(object): Sample interface type __metaclass__ = ABCMeta @abstractmethod def requiredCall(self): return class TestType1(object):
class Anketum < ActiveRecord::Base has_one :user class << self def search(params) self.scope :h, :conditions
class MyClass(object): def __init__(self): self._my_secret_thing = 1 def _i_get(self): return self._my_secret_thing def _i_set(self, value):
class ShortInputException(Exception): '''A user-defined exception class.''' def __init__(self, length, atleast): Exception.__init__(self) self.length = length
class A(object): _all = set() def __new__(cls): obj = super(A,cls).__new__(cls) cls._all.add(obj) return obj class
class test: def __init__(self, val): self.val = val self.val.lower() Why doesn't lower() operate on
class foo { public: void set(const int a) {b=a;} private: int b; }; Here
class CreateMatches < ActiveRecord::Migration def self.up create_table :matches do |t| t.integer :result_home t.integer :result_away
class ToBeDeleted: def __init__(self, value): self.value = val # Whatever... def __del__(self): print self.value

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.