Discuss Scratch
- everwinner64
-
Scratcher
1000+ posts
Sujets Avancés
Bonjour, depuis quelques jours, j’ai un problème auquel je ne trouve aucune explication, ni solution « native » au problème. J’ai besoin de créer un cookie avec une date de péremption. Mon code fonctionne sur ce point, mon navigateur le reconnaît entièrement, mais quand la date de péremption est atteinte, le cookie n’est pas supprimé, que je ferme ou non le navigateur. J’ai eu beau chercher quelle sombre raison en est la cause, mais je n’ai rien trouvé. Savez-vous ce qui pourrait causer ça ?
Le code qui crée le cookie :
Le code qui crée le cookie :
await cookieStore.set({ name: "visited-page", value: "true", expires: Date.now() + 12 * 60 * 60 * 1000, sameSite: "strict", path: "/" });
Last edited by everwinner64 (Nov. 17, 2025 18:26:36)
- wilhelm43
-
Scratcher
1000+ posts
Sujets Avancés
Il me semble que javascript ne prend pas en compte les opérations dans un dictionnaire. Essaye en définissant une variable expire au préalable, pour voir ?
Sinon, ça peut venir aussi de ton navigateur.
Sinon, ça peut venir aussi de ton navigateur.
- Blaireau2012
-
Scratcher
15 posts
Sujets Avancés
Salut!
J'espère avoir choisis le bon topic parce que j'ai besoin d'aide pour un projet arduino.
J'ai un Arduino uno wifi rev2 et j'ai fait un code en m'inspirant de celui-là.
Je vous le met :
Je le téléverse sur mon arduino, il se connecte bien, puis j'ouvre mon naviguateur(firefox, window) et je n'arive pas a l'afficher, parce que la connextion n'est pas sécurisée. Pourtant, sur un ordi mac (safari) et un smartphone(androïd), la page s'affiche bien.
Comment le modifier pour qu'il marche?
Merci d'avance.
J'espère avoir choisis le bon topic parce que j'ai besoin d'aide pour un projet arduino.
J'ai un Arduino uno wifi rev2 et j'ai fait un code en m'inspirant de celui-là.
Je vous le met :
#include <WiFiNINA.h>
char ssid[] = ""; // your network SSID (name) between the " "
char pass[] = ""; // your network password between the " "
int keyIndex = 0; // your network key Index number (needed only for WEP)
int status = WL_IDLE_STATUS; //connection status
WiFiServer server(80); //server socket
WiFiClient client = server.available();
int ledPin = 2;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
while (!Serial);
enable_WiFi();
connect_WiFi();
server.begin();
printWifiStatus();
}
void loop() {
client = server.available();
if (client) {
printWEB();
}
}
void printWifiStatus() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your board's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
Serial.print("To see this page in action, open a browser to http://");
Serial.println(ip);
}
void enable_WiFi() {
// check for the WiFi module:
if (WiFi.status() == WL_NO_MODULE) {
Serial.println("Communication with WiFi module failed!");
// don't continue
while (true);
}
String fv = WiFi.firmwareVersion();
if (fv < "1.0.0") {
Serial.println("Please upgrade the firmware");
}
}
void connect_WiFi() {
// attempt to connect to Wifi network:
while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection:
delay(10000);
}
}
void printWEB() {
if (client) { // if you get a client,
Serial.println("new client"); // print a message out the serial port
String currentLine = ""; // make a String to hold incoming data from the client
while (client.connected()) { // loop while the client's connected
if (client.available()) { // if there's bytes to read from the client,
char c = client.read(); // read a byte, then
Serial.write(c); // print it out the serial monitor
if (c == '\n') { // if the byte is a newline character
// if the current line is blank, you got two newline characters in a row.
// that's the end of the client HTTP request, so send a response:
if (currentLine.length() == 0) {
// HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
// and a content-type so the client knows what's coming, then a blank line:
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.println();
//create the buttons
client.print("Click <a href=\"/H\">here</a> turn the LED on<br>");
client.print("Click <a href=\"/L\">here</a> turn the LED off<br><br>");
int randomReading = analogRead(A1);
client.print("Random reading from analog pin: ");
client.print(randomReading);
// The HTTP response ends with another blank line:
client.println();
// break out of the while loop:
break;
}
else { // if you got a newline, then clear currentLine:
currentLine = "";
}
}
else if (c != '\r') { // if you got anything else but a carriage return character,
currentLine += c; // add it to the end of the currentLine
}
if (currentLine.endsWith("GET /H")) {
digitalWrite(ledPin, HIGH);
}
if (currentLine.endsWith("GET /L")) {
digitalWrite(ledPin, LOW);
}
}
}
// close the connection:
client.stop();
Serial.println("client disconnected");
}
}
Comment le modifier pour qu'il marche?
Merci d'avance.



