title: How to assign BSON _Id to a cookie (Go, Mongodb)
body: <p>I was trying to create a go cookie. I want to assign Id from Mongodb to be stored in the Cookie. But while compiling I am getting an error as follows:-</p>
  
  <p>"unknown http.Cookie field 'Id' in struct literal"</p>
  
  <p>The following is my code:-</p>
  
  <pre><code>getUser := user.CheckDB()
  expiration := time.Now().Add(365 * 24 * time.Hour)
  
  //The Error is Caused by the Next Line
  cookie := http.Cookie{Id: getUser[0].Id, Name: getUser[0].Email, Value: getUser[0].Password, Expires: expiration}
  http.SetCookie(w, &amp;cookie)
  
  
  
  func (this *User) CheckDB() []User {
      var results []User
      sess, db := GetDatabase()
      defer sess.Close()
      c := db.C("user")
      uname := &amp;this.Email
      err := c.Find(bson.M{"email": *uname}).Sort("-id").All(&amp;results)
      if err != nil {
          panic(err)
      } else {
          fmt.Println("Results All: ", results)
          return results
      }
  }
  
  type Cookie struct {
      Id         bson.ObjectId `bson:"_id,omitempty"`
      Name       string
      Value      string
      Path       string
      Domain     string
      Expires    time.Time
      RawExpires string
      MaxAge     int
      Secure     bool
      HttpOnly   bool
      Raw        string
      Unparsed   []string
  }
  </code></pre>
  
  <p>Thanks in advance.</p>