We help IT Professionals succeed at work.

Session on Html

Whing Dela Cruz
on
156 Views
Last Modified: 2017-04-10
Hi experts, I'm trying to change the value of Session inside the script but it doesn't work. Any help please!

<script>
function ChangeSession()
{
    Session("AllowT") = "T"
}
</script>

Open in new window

Comment
Watch Question

CERTIFIED EXPERT

Commented:
session should runs at server side not like javascript which runs on client side.

do you mean something like this?

<script>
function ChangeSession()
{
<%
    Session("AllowT") = "T"
%>
  var t = "<%=Session("AllowT")%>";
   alert("T = " + t);
}
</script>

Open in new window

This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
CERTIFIED EXPERT

Commented:
can I do something like variable declared in script and put the value in Session?
you probably can't until you do a posting to server side.

to change something on Session, you need to do it on server side end.

hope this clarifies.
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2019
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Author

Commented:
Thanks a lot Julian, your explanation gives more clearer to me. I will try it now!

Author

Commented:
Thank you both of guys, your  comments and suggestion helps me a lot to understand. More power to both of you and May God give more knowledge to help those who are in need!
CERTIFIED EXPERT

Commented:
@Whing Dela Cruz

are you accepting your own comment as the assisted answer?
CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2019

Commented:
You are welcome