Open MGlolenstine opened 4 years ago
I am unsure as to what you mean by "won't get loaded at the next webpage load". Aren't files stored to localstorage consistent between sessions?
I am unsure as to what you mean by "won't get loaded at the next webpage load". Aren't files stored to localstorage consistent between sessions?
Correct... localStorage
does persist, but I need to load cookies for the first website request and I can't access localStorage
or cookies
without JS, which is a problem, as I have to set cookies before first request, otherwise I just get blocked by "unauthorised".
You could build the webview first then use eval to execute the necessary javascript and then run the webview..
let mut webview = builder().......
...build().unwrap();
webview.eval(r#"
your js code here
"#);
webview.run().unwrap(); ?
You could build the webview first then use exec to execute the necessary javascript and then run the webview..
let mut webview = builder()....... ...build().unwrap(); webview.exec(r#" your js code here "#); webview.run().unwrap(); ?
I had no idea I was able to run JS without having to load a website first 😮. I'll try this out and will report back!
webview
doesn't include exec
function. The code is located after the .build().unwrap()
.
error[E0599]: no method named `exec` found for struct `web_view::WebView<'_, bool>` in the current scope
--> src/main.rs:49:13
|
49 | webview.exec(r#"
| ^^^^ method not found in `web_view::WebView<'_, bool>`
.eval()
on the other hand works!
Ah shoot my apologies, I got confused between exec and eval for a second since I was using qt recently... Anyways, Glad it works.
If you have no other issues, close the Issue btw!
If you have no other issues, close the Issue btw!
I haven't solved the cookies yet, I just managed to get the JS working before the WebView loads ;) I will close it once I have it working! :+1: I'm currently at work, so I'll try more stuff once I get home.
Has anyone come across a solution for this? I just did a quick test and localStorage doesn't seem to persist between runs.
It would be awesome if we could pass a path to the builder where the cookies can be found/stored. I realise that could be almost impossible if not implemented in the C library though.
This is quite a must-have feature and I will explain why.
With no persistent cookies support (or at least to have the ability to load cookies from file) you are pretty much doomed from all application behind login or from applications where you need some kind of personalization.
Please give tauri a shot https://github.com/tauri-apps/tauri
Tauri is a whole different level and tool. Also using another tool doesn't resolve this issue.
How would one keep cookies between sessions?
EDIT: I can save them using the localStorage, but they won't get loaded at the next webpage load.