Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

django cookies

def setCookie(request):
  	response = render(request,"index.html")
    maxAge = 1 * 24 * 60 * 60
    response.set_cookie("key", "value", max_age = maxAge) # max_age = 1 day
    
def getCookie(request):
  	value = request.COOKIES.get('key')
  	if value is None:
    	# Cookie is not set
Comment

cookies in django

def setcookie(request):
    html = HttpResponse("<h1>Dataflair Django Tutorial</h1>")
    html.set_cookie('dataflair', 'Hello this is your Cookies', max_age = None)
    return html
Comment

cookies in django

# views.py
def viewdata(request):
  #  html file index.html
    response = render(request,"index.html")
  # Set Cookies
    response.set_cookie('mefiz', 'mefiz.com') 
	# Get Cookies
    value = request.COOKIES.get("mefiz")
    print(value)
    # Return Responce
    return response
Comment

PREVIOUS NEXT
Code Example
::  
::  
::  
Python ::  
Python ::  
::  
::  
::  
::  
::  
:: python remove empty lines from file 
Python ::  
::  
Python ::  
::  
::  
::  
::  
::  
::  
::  
::  
::  
::  
::  
Javascript ::  
::  
::  
::  
Javascript ::  
ADD CONTENT
Topic
Content
Source link
Name
5+1 =