i know session variables store on the server side and cookies store on client side.

Question: If i save the total answer for a summation as a session variables, and multiple online user are using the same system for calculation, does that means that session variable will be over write by other value where other user have different summation answer?

Dani AI

Generated

Short answer: storing each user’s summation in Session is fine — one visitor’s Session data won’t be silently overwritten by another visitor’s Session. has the core point right. A few practical caveats and checks follow.

  • Verify you are using Session(...) and not Application(...) or a global variable; Application is shared across all users and will be overwritten.
  • If multiple people share the same browser/profile (or the same machine and account), they share the same session cookie and thus the same Session.
  • If the browser blocks cookies, classic ASP will not be able to keep a single session across requests (you’ll see new sessions); likewise a load‑balanced farm without sticky sessions or an external session store can appear to “lose” or change session data.
  • Sessions consume server memory. Don’t store large data structures there if your site must scale.

Recommended practice: store small, per‑visit items (user id, a temp token, small totals) in Session. For persistent cross‑visit data use a database or a validated token/cookie that maps to server data. Never trust cookie values as authoritative — always validate on the server.

Quick classic‑ASP examples (VBScript):

<%
' store per-user value
Session("SumTotal") = total
Session.Timeout = 30

' persistent client cookie (expires in 7 days)
Response.Cookies("SavedTotal") = total
Response.Cookies("SavedTotal").Expires = DateAdd("d", 7, Now())

' read back
total = Session("SumTotal")
saved = Request.Cookies("SavedTotal")
%>

If sessions behave oddly, add a simple debug page that dumps Request.Cookies and your codebase for any Application(...) usage or global variables.

Do you mean if one user's action will change the other's session value?

Server will creates a new Session for each new user, and destroys the Session when it is expires. User cannot modify the other users' seesion value.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.