我在第 1 页有一个表格:
<form method="post" action="request-form">
<input
type="text"
id="amzQry"
name="item"
placeholder="What do you need?"
autocomplete="on"
/>
<input
id="autocomplete"
name="destination"
placeholder="where? (e.g. Buenos Aires)"
onfocus="geolocate()"
type="text"
required=""
aria-required="true"
autocomplete="off"
/>
<button type="submit" value="">
Submit
</button>
</form>
Run Code Online (Sandbox Code Playgroud)
我希望以持久的方式保存此信息,以便即使用户随后登录(在本例中为 joomla),cookie 数据也是持久的并且可以被调用。这就是为什么我在这种情况下使用 cookie 而不是会话。如果这不是正确的方法,请纠正我。
我有一些代码来设置和检索第 2 页上的 cookie:
<?php
$itemcookie = $_POST['item'];
$detsinationcookie = $_POST['destination'];
setcookie("itemcookie", $itemcookie, strtotime('+30 days'));
setcookie("destinationcookie", $detsinationcookie, strtotime('+30 days'));
?>
Run Code Online (Sandbox Code Playgroud)
但是,当表单提交后加载时,cookie 数据不会出现在第二页上。如果我刷新第二页,数据会出现在正确的位置,即我用例如调用它的位置
<?php
echo $_COOKIE["itemcookie"];
?>
Run Code Online (Sandbox Code Playgroud)
如何立即在第2页获取可用的cookie数据?
我有一个Message
结构,它有一个字段,我想在调用方法时修改它。
这个Message
结构有一个attachments
字段,它是一个Option<Vec<Attachment>>
.
我的目标是能够调用一个方法Message
来将一个Attachment
对象推送到attachments
Vec
.
#[derive(Debug, Serialize, Deserialize)]
pub struct Message {
/// The verified sender email address
#[serde(rename = "FromEmail")]
pub from_email: String,
/// The name of the sender
#[serde(rename = "FromName")]
pub from_name: String,
/// The subject of the email
#[serde(rename = "Subject")]
pub subject: Option<String>,
/// The raw text content of the email
#[serde(rename = "Text-part")]
pub text_part: String,
/// The HTML content of …
Run Code Online (Sandbox Code Playgroud)