草庐IT

one_cookie

全部标签

go - Cookie 不使用 Golang 设置

我有一个用于登录用户的RESTAPI,它在浏览器上为登录用户设置一个cookie,并且运行良好。问题是当用户从注册API完成注册时我想调用登录​​API,这样每件事都运行良好但cookie未设置为浏览器。这是登录API:varloginViaDjangoApiShim=http.HandlerFunc(func(whttp.ResponseWriter,r*http.Request){vartloginPostvaroldCookieTokenstringdecoder:=json.NewDecoder(r.Body)_:=decoder.Decode(&t)expiration:=t

戈朗 : Can I apply helper function to one of the returned arguments

假设我有connection:=pool.GetConnection().(*DummyConnection)其中pool.GetConnection返回interface{},我想将其转换为DummyConnection。我想更改GetConnection接口(interface)以返回错误。代码开始看起来像这样:connectionInterface,err:=pool.GetConnection()connection:=connectionInterface.(*DummyConnection)我想知道,我是否可以避免使用辅助变量并将它们放在一行中?

go - 如何读取cookie?

我通过javascript设置了一个cookie,例如:setCookie("appointment",JSON.stringify({appointmentDate:selectedDay.date,appointmentStartMn:appointment.mnRange[0],appointmentId:appointment.id||0,appointmentUserId:appointment.user.id||0}));设置cookie后,我想将用户重定向到预订页面:window.location.href="https://localhost:8080/booking/

go - 设置 cookie 不被检测

我在尝试检索已设置的cookie时遇到问题,如果未设置,我想更新它然后检索它。首先,我有一个设置cookie的函数:funcIndexHandler(whttp.ResponseWriter,r*http.Request){...ck:=http.Cookie{Name:"id",Value:5,MaxAge:60,}}然后在另一个函数中我检查该cookie是否存在,如果它(抛出错误)然后我重新创建它funcCheckUpdateCookie(whttp.ResponseWriter,r*http.Request){val,err:=r.Cookie("id")iferr!=nil{c

google-app-engine - CookieJar 不捕获传入的 cookie

我正在尝试让Go在网页上为我提交一个表单来模拟登录。从那里我尝试使用cookie来保持持久session,以便再次调用子页面。我能够毫无问题地成功登录,我只是在捕获返回服务器设置的cookie时遇到了问题。我想知道是不是因为他们的登录脚本做了几次重定向?(我得到一个输出)。为什么我没有捕捉到返回的cookie有什么想法吗?这是我使用的代码:import("crypto/tls""fmt""io/ioutil""net/http""net/url""strings""sync")typeJarstruct{lksync.Mutexcookiesmap[string][]*http.Coo

ios - CCCrypto解密: exactly one block less

我正在尝试解密由golang脚本加密的字符串。加密是CBC,key大小为256。16个字节长的iv包含在密文的开头,如golang文档所建议的那样。一切正常,除了objc代码总是丢失最后一个block。例如当我期望返回80个字节但只得到64个字节时,期望返回128个字节但得到112个字节。有什么建议吗?谢谢!golang代码funcencrypt(text_s,key_sstring)byte[]{text:=[]byte(text_s)//paddingtextn:=aes.BlockSize-(len(text)%aes.BlockSize)log.Println("Needtop

mongodb - 如何将 BSON _Id 分配给 cookie(Go,Mongodb)

我正在尝试创建一个gocookie。我想从Mongodb分配Id以存储在Cookie中。但是在编译时出现如下错误:-“结构文字中的未知http.Cookie字段‘Id’”以下是我的代码:-getUser:=user.CheckDB()expiration:=time.Now().Add(365*24*time.Hour)//TheErrorisCausedbytheNextLinecookie:=http.Cookie{Id:getUser[0].Id,Name:getUser[0].Email,Value:getUser[0].Password,Expires:expiration}

go - Rethinkdb,去 : Ensure Table and Index in one ReQL statement

我需要确保在应用程序启动时存在表。如果表不存在需要创建,我还想在表上创建二级索引。这在Go中很容易完成,但我想在ReQL中用一条语句完成。所以我想到了这个:funcensureTableIndex(ses*r.Session,namestring,indexstring)(errerror){err=r.TableList().Contains(name).Do(r.Branch(r.Row,r.Expr(nil),r.Do(func()r.Term{returnr.TableCreate(name).Do(func()r.Term{returnr.Table(name).IndexC

cookies - 使用 Go 客户端接收和发送 cookie?

我希望我的Go应用程序通过网站进行身份验证,然后使用收到的cookie访问安全位置。以下curl示例准确说明了我正在尝试做的事情:通过x-www-form-urlencoded对网站进行身份验证并保存cookie。数据自动进行urlencoded:curl'https://www.example.com/login'\--cookie-jarcookies.txt\--header'Content-Type:application/x-www-form-urlencoded'\--data'user=USERNAME&pass=PASS'现在身份验证cookie保存在cookies.t

rest - 在 API Rest golang 中发送 cookie

我在Golang工作,我正在构建一个API-Rest并且想知道,我可以使用restful设置cookies吗?我正在构建与用户身份验证相关的方法:登录、注销、注册等,现在我正在尝试使用生成的uuid在响应中设置cookie。我有这个:funcLogin(whttp.ResponseWriter,req*http.Request,pshttprouter.Params){...somecode....c:=&http.Cookie{Name:"session",Value:uuid.NewV4().String(),}http.SetCookie(w,c)w.Header().Set("