The datastore has a Key property, which is made up of (optional) ancestors, the kind, and a name or id. However, there is no specific id property. (Reference)
To get an entity with a specific key, your code should look something like this:
# Get cookie
user_id = self.request.cookies.get("user_id", 0)
if not user_id:
# handle this case, otherwise the call to from_path will fail.
# Build key
user_key = db.Key.from_path('User', long(user_id))
# Get the entity
user = db.get(user_key)
# If a user is found, display the username
if user.username:
signup = "Welcome, %s" % user.username
You actually don't want to use a query in this case because you already know the key of the entity you are looking for.
When you are querying with keys, you have to specify the entire key (not just the id):
user = db.GqlQuery("SELECT * FROM User WHERE __key__ > KEY('User', %s)" % user_id).get()
Notice here I am using an inequality, since using an equality filter for a key does not make sense given that you can do a direct lookup. Here is the reference for using KEY in a GQL string and I've quoted the relevant section below:
The right-hand side of a comparison can be one of the following (as appropriate for the property's data type):
an entity key literal, with either a string-encoded key or a complete path of kinds and key names/IDs:
KEY('encoded key')
KEY('kind', 'name'/ID [, 'kind', 'name'/ID...])