Using Twilio Python to Get and Set Cookies

The definitive guide to Twilio conversation tracking uses outdated code as twiml no longer has a method Response(). Is it still possible to track conversations with cookies?

from flask import Flask, request, make_response
from datetime import datetime, timedelta
from twilio import twiml

app = Flask(__name__)

@app.route("/sms")
def sms():

    #get the cookie value, or default to zero
    messagecount = int(request.cookies.get('messagecount',0))
    messagecount += 1

    twml = twiml.Response()
    twml.sms("You've sent " + str(messagecount) + " messages in this conversation so far")

    resp = make_response(str(twml))

    expires=datetime.utcnow() + timedelta(hours=4)
    resp.set_cookie('messagecount',value=str(messagecount),expires=expires.strftime('%a, %d %b %Y %H:%M:%S GMT'))

    return resp

if __name__ == "__main__":
    app.debug = True
    app.run()

Forms authentication cookie not honoring timeout in web.config

I have a static machine key in my web.config and I’m trying to get my auth cookie to be persistent with a timeout of two hours with a sliding window. I’m use the following web.config values

<authentication mode="Forms">
  <forms name="DealerVisionApp" domain=".dealervision.local" loginUrl="/" timeout="120" slidingExpiration="true" />      
</authentication>

When I fully authenticate the cookie is labeled as a non-persistent session cookie and is tied to the timeout of my session. While testing I set the session timeout to 1 minute and after one minute without fail the auth cookie is expired and I have to log in again.

Why is this not being obeyed?

Alamofire cookies error on WatchOS

I am using the latest Alamofire library in my iOS app and my Watch app. Everything works fine on the iOS app, however when I make a HTTP POST request to a certain URL to login the user on the Watch app, the login page throws an error saying that

Your browser is not accepting cookies or that you are manually
accepting some cookies but not others.

You must accept all cookies for to work – please check whether you
are receiving cookies and try to login again

I am sharing the same networking code between the iOS and Watch app, so I am 100% sure it’s not an issue with my code, and anyway, it works fine on the iOS app.

I also tried using a URLSession with custom configuration where configuration.httpCookieAcceptPolicy = HTTPCookie.AcceptPolicy.always, but that didn’t solve the problem as well.

Does anyone know what could be the issue?

wordpress “cookie error login” after removing W3 Total cache

i wanna to unistalling w3 totoal cache so disable their options and then Disable it in plugins
after that
the login page don’t working by below error
ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress

You should know its about W3 and it’s not about browsers…

Set enhanced privacy on YouTube using the iframe.js API? [on hold]

I’ve seen references to using www.youtube.nocookie to set enhanced privacy on YouTube using an iframe. This prevents YouTube from setting cookies until the user clicks on the video to play it. Does anyone know how to do this using the javascript iframe API? (Needed for GDPR / e-Privacy compliance).

How can I capture & track an AdWords user from outside of the browser?

I have a PC (Windows, OSX, Linux) video game on the Steam marketplace and an extremely common problem for us developers is that there is no way to find out if a user who clicked on our game through our AdWords campaign, has actually bought it. Steam provides some analytics tracking up until our game page, but it falls into a black box after that.

I have all the power in the world once the user opens our game, so my thought here is that surely we can find the AdWords tracking ID/cookie and manually POST that to our Google Analytics platform?

I suppose step 1 is – How do we make our AdWords campaign leave a long lasting cookie/tracking ID somewhere?
Step 2 – How do I find it and POST it?

How do i update an array within a cookie?

I’m saving a cart array within a cookie, to send it to the shopping cart page. Whenever i go to a page from another product and click on add to cart it doesn’t add it to the array, but seems to overwrite it.

$uri = $_SERVER['REQUEST_URI'];
$pin = explode('/', $uri);
$id = $pin[3]; 

$product = $model->selectById($id, 'carpet');
$product = $product->fetch(PDO::FETCH_ASSOC);

$site_url = site_url();
if(!$product){
    header("Location: $site_url./404");
}

if(isset($_POST['add'])){
    $cart = [];
    $cart[$product['id']] = [];
    $cart[$product['id']]['product_name'] = $product['name'];

    setcookie('cart', serialize($cart), time()+3600);
    $cart = unserialize($_COOKIE['cart']);
     dd($cart);
}

How do i update an array within a cookie?

I’m saving a cart array within a cookie, to send it to the shopping cart page. Whenever i go to a page from another product and click on add to cart it doesn’t add it to the array, but seems to overwrite it.

$uri = $_SERVER['REQUEST_URI'];
$pin = explode('/', $uri);
$id = $pin[3]; 

$product = $model->selectById($id, 'carpet');
$product = $product->fetch(PDO::FETCH_ASSOC);

$site_url = site_url();
if(!$product){
    header("Location: $site_url./404");
}

if(isset($_POST['add'])){
    $cart = [];
    $cart[$product['id']] = [];
    $cart[$product['id']]['product_name'] = $product['name'];

    setcookie('cart', serialize($cart), time()+3600);
    $cart = unserialize($_COOKIE['cart']);
     dd($cart);
}

POST requests with cookie

I’m trying to send post requests with payload to automate an entry. The url is: https://gleam.io/wOAtd/air-jordan-iii-free-throw-line.

#
payload = {
    email and address
}
headers = {
    "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"
}
r1 = requests.get(
    'https://gleam.io/wOAtd/air-jordan-iii-free-throw-line'
)
print("r1", r1.status_code)
r2 = requests.post(
    'https://gleam.io/set-contestant',
    data = payload, cookies = r1.cookies,
    headers = headers)
print("r2", r2.status_code)

I’m getting 200 from r1 but 500 from r2. What else should I do? If you provide an answer please explain what you look for in network”.