This is how you store data:
 request.session['member_id'] = m.id
This is how you read it:
 request.session['member_id']

Your view code looks fine, in respect of how you use sessions. I can't see
that you have explained what problem you are having: what is going wrong?

Finally, you do have to do some minimal configuration to enable sessions.
Are you sure you have done that?

On Thu, Aug 2, 2012 at 10:42 AM, Gregory Thompson Jr. <
spockthompso...@gmail.com> wrote:

> Then how do I use the session to pass data between views?  What's wrong
> with my code?
>
> If it counts for anything, *'text'* returns *'None'* in my debug
> statements (in the results() view).
>
>
> On Thursday, August 2, 2012 10:38:40 AM UTC-4, Marcin wrote:
>>
>> What's confusing about this? You don't explicitly create sessions, and
>> they last as long as they are configured to last, which by default is until
>> the session cookie is cleared.
>>
>> On Thu, Aug 2, 2012 at 10:31 AM, Gregory Thompson Jr. <
>> spockthompso...@gmail.com> wrote:
>>
>>>
>>>    1. def login(request):
>>>    2.     m = Member.objects.get(username=**request.POST['username'])
>>>    3.     if m.password == request.POST['password']:
>>>    4.         request.session['member_id'] = m.id
>>>    5.         return HttpResponse("You're logged in.")
>>>    6.     else:
>>>    7.         return HttpResponse("Your username and password didn't
>>>    match.")
>>>
>>> How about that for starters?
>>>
>>> The documentation goes from that to explaining how to set cookies.  How
>>> do they expect me to understand what's going on?
>>> There's absolutely NO explanation of what's going on in that code.
>>>
>>>         request.session['member_id'] = m.id
>>>
>>> How the hell does that work?
>>>
>>> They don't tell you where the session is started, how, what the scope of
>>> the session declaration is, etc...
>>>
>>> http://www.youtube.com/watch?**v=YFd9NLZFmvo&playnext=1&list=**
>>> PL6CB0A9FA1D9C736A&feature=**results_video<http://www.youtube.com/watch?v=YFd9NLZFmvo&playnext=1&list=PL6CB0A9FA1D9C736A&feature=results_video>
>>>
>>>
>>> See that video?  The video shows you how to use sessions very quickly.
>>>  How did the person in the video get ALL of that code from just the
>>> documentation?
>>>
>>> If all readers in this thread and kindly tackle each point I made, I
>>> promise you your own KFC when I start my empire.  Until then, I really just
>>> need someone to give me the step-by-step on this one.  I'm completely new
>>> to the framework and the documentation thus far has not been helpful.  I've
>>> mainly gotten by with the help of StackOverflow, IRC, and random code
>>> snippets online -- and occasionally, some outdated books.
>>>
>>> If you don't want to explain or aren't going to ask me progressive
>>> questions with regards to my confusion, please just skip over my plight.
>>>
>>> Thank you all.
>>>
>>> On Thursday, August 2, 2012 9:54:21 AM UTC-4, Daniel Roseman wrote:
>>>>
>>>> On Thursday, 2 August 2012 14:06:04 UTC+1, Gregory Thompson Jr. wrote:
>>>>>
>>>>> <snip>
>>>>>
>>>>> I really don't understand the following, and I've read the documentation 
>>>>> over and over.  I've been on this for two days:
>>>>>
>>>>>
>>>>>    - How to initiate a session
>>>>>    - How sessions are checked
>>>>>    - How to retrieve form data from one page to handle the data on 
>>>>> another.
>>>>>
>>>>> Again, I've read through the documentation.  I've asked on IRC but 
>>>>> everyone pretty much just says "RTFM" even when I tell them I have.  This 
>>>>> is absolutely frustrating as an extreme beginner.
>>>>>
>>>>> I'd also like to add that I DO understand the core Python language.  
>>>>> Please, unless it's absolutely necessary, don't try explaining to me what 
>>>>> a dictionary, tuple, list, etc... is.  I've already had my intelligence 
>>>>> insulted by the users on IRC in this regard.  I really just don't 
>>>>> understand the sessions documentation.
>>>>>
>>>>>
>>>>
>>>> So, you didn't understand the documentation, but you also don't want to
>>>> be told what dictionaries/lists/tuples are.  How about you tell us which
>>>> bit of the examples under "Using sessions in views" (which I'm not linking
>>>> to because you've said you've read it) you didn't understand?
>>>> --
>>>> DR.
>>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To view this discussion on the web visit https://groups.google.com/d/**
>>> msg/django-users/-/0czW05_**b8q8J<https://groups.google.com/d/msg/django-users/-/0czW05_b8q8J>
>>> .
>>>
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to django-users+unsubscribe@*
>>> *googlegroups.com <django-users%2bunsubscr...@googlegroups.com>.
>>> For more options, visit this group at http://groups.google.com/**
>>> group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
>>> .
>>>
>>
>>
>>
>> --
>> Marcin Tustin
>> Tel: 07773 787 105
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/GIPMRuHoti8J.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Marcin Tustin
Tel: 07773 787 105

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to