How to use cookies in selenium?

It is necessary to visit the site with family cookies (already authorised or for example with the filled basket in the online shop)
What I tried:
1)
System.setProperty("webdriver.chrome.driver","E:\\Roma\\prog\\Java\\project\\yandex\\driver\\chromedriver.exe");
 ChromeOptions opt = new ChromeOptions();
 opt.setBinary("C:\\Program Files (x86)\Google\\Chrome\\Application\\chrome.exe");
 opt.addArguments("--user-data-dir=C:\\Users\\Roma\\AppData\\Local\\Google\\Chrome\\User Data");

 Non-ie web browsers driver=new non-ie web browsers(opt);

 driver.get("https://site.ru/checkout");

This is the code to open the native chrome, and not one that selenium opens by default.
error:
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
2)
Cookie Cookie = new Cookie.Builder("name", "value")
.domain(".mydomain.com")
 .expiresOn(new Date(2015, 10, 28))
.isHttpOnly(true)
.isSecure(false)
.path("/mypath")
.build();

driver.manage().addCookie(cookie);

just nothing happening here, perhaps due to the fact that I cookies are not correct installed, because to put them on a normal not out.
3) the idea was to open a browser, selenium, where to login, and then open the second tab in the same page and to work with her. But not enough sense to realize it.
I like the first option, when you just open your own browser which has all the cookies there, but throws out an error.
March 12th 20 at 08:39
1 answer
March 12th 20 at 08:41
"to open a browser in selenium, there is a log in"
for me it is a much better solution than the two options above.

But not enough sense to realize it

so what is the problem exactly?
Filled out the form and went?

The only thing it is important to understand that selenium is necessary browser tabs to switch not to forget, if the other go.

Find more questions by tags SeleniumJava