Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Assign Value To Session Using Javascript

Tags:

javascript

Work on Asp.Net C# VS08 I would like to assign a value to Session using javascript. Is it possible?

example: Session["Id"] = document.getElementById("id").value;

like image 230
HelloBD Avatar asked Dec 05 '25 10:12

HelloBD


1 Answers

The session is a server-side concept; Javascript has no conception of it.

You can make an AJAX service that sets a session value.

However, you should probably use a cookie instead.
You can set cookies in Javascript using this library, among others.

like image 71
SLaks Avatar answered Dec 08 '25 14:12

SLaks