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 :: django custom save method 
Python :: isnumeric 
Python :: iso date convert in python 
Python :: python file.write is not writing whole line 
Python :: __str__() 
Python :: python name input 
Python :: read csv and store in dictionary python 
Python :: find all files containing a string in python with glob module 
Python :: calculate days between two dates python 
Python :: function without return python 
Python :: python remove whitespace from start of string 
Python :: numpy euclidean distance 
Python :: How to remove all characters after character in python? 
Python :: change dataframe value by index 
Python :: python remove punctuation 
Python :: sieve of eratosthenes python 
Python :: kafka get last offset of topic python 
Python :: python basic flask app 
Python :: get input from user in python 
Python :: last executed query in flask api 
Python :: remove extra spaces and empty lines from string python 
Python :: how to capitalize the first letter in a list python 
Python :: changing plot background color in python 
Python :: failed to execute script 
Python :: defualt image django 
Python :: how to mention a div with class in xpath 
Python :: how to fill nan values in pandas 
Python :: Sum values of column based on the unique values of another column 
Python :: isolate row based on index pandas 
Python :: get title beautifulsoup 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =