On Feb 14, 7:00 am, "samira" <[EMAIL PROTECTED]> wrote: > we can have two ways to store data in cookie: Session for permanent > and cookie for temporary. Am I right?
Not exactly. Data stored in session is held on the server. The session middleware uses a cookie to give the client a session id so that the session data can be tied back to that client. By default the session cookie stays on the client for a couple of weeks, rather than being removed when the browser is closed. You can add your own cookies to the client to store whatever information you need. By default they will be removed when the browser is closed. These cookies are not related to the session. > I used "response.setcookie" but > my problem not solve yet :( can you tell me how create httpResponse > object? Every view function returns an HttpResponse of some sort. You can add your cookies to the response before returning it. For example, if you had: def index(request): return render_to_response('index.html') You could add a cookie before returning the response: def index(request): response = render_to_response('index.html') response.set_cookie('test', value='test cookie was set') return response In this or another view you can then get the cookie back using: request.COOKIES['test'] Scott --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---