You can set the time based off the current time. Double check this code. You can test it out in your browserās developer tools to see that itās working. The math could be simplified.
<script type="text/discourse-plugin" version="0.8">
if (api.getCurrentUser()) {
const now = new Date();
let time = now.getTime();
time += 60 * 60 * 24 * 7 * 1000; // seconds * minutes * hours * days * milliseconds
now.setTime(time);
document.cookie = "logged_in=true; expires=" + now.toUTCString();
}
</script>