ayush2917 commited on
Commit
2801701
·
verified ·
1 Parent(s): 1c321a3

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +3 -1
templates/index.html CHANGED
@@ -216,10 +216,12 @@
216
  userId = 'user_' + Math.random().toString(36).substr(2, 9);
217
  localStorage.setItem('user_id', userId);
218
  }
 
 
219
  return userId;
220
  }
221
 
222
- const currentUserId = getUserId();
223
 
224
  document.getElementById('prefs-form').addEventListener('submit', async (e) => {
225
  e.preventDefault();
 
216
  userId = 'user_' + Math.random().toString(36).substr(2, 9);
217
  localStorage.setItem('user_id', userId);
218
  }
219
+ // Set the user_id as a cookie so the backend can access it
220
+ document.cookie = `user_id=${userId}; path=/; max-age=${60 * 60 * 24 * 365}`; // Expires in 1 year
221
  return userId;
222
  }
223
 
224
+ const currentUserId = getUserId(); // Call getUserId immediately to ensure cookie is set
225
 
226
  document.getElementById('prefs-form').addEventListener('submit', async (e) => {
227
  e.preventDefault();