How do I make a welcome message based on what specific user enters a webpage? For example, if "John" enters a website it will say "Welcome, John". Does it involve session variables?
Well, first you have to get input from users like asking his name through a form. And yes you can use session but u can also use variables like this. First Page of your site. Your Name ------------- "User will enter his name here" On next page you can recall it through variable and write however you want. If you have a membership system on your site, then you can use session as well. But for general public just use the variable. If you have understood what i have said, start doing it and what ever problem you face, share it here, i will help you.
if it is a dynamic site based on SQL, once you have logged him in you have his details and you can keep it in a session variable. Then just concatanate the value of the session to the rest of the sentense Pseudo code example (after log-in has executed) : Response.write session("FullNameFromDB") + " Welcome back" If John had entered (not logged-in) to a previously visited site you do the same thing but from a cookie: Pseudo-code: Response.write Cookie("FullNameFromDB") + " Welcome back"
store a custom object class in the session state, which can be done from a global handler (asax) somewhat like: /// <summary> /// Load Current User Session ID /// </summary> protected void LoadSessionID() { if (base.Session["ID"] != null) { SessionID = (ulong)base.Session["ID"]; } else { lock (Serials) { byte[] Buffer = new byte[8]; Gen.NextBytes(Buffer); ulong NewID = BitConverter.ToUInt64(Buffer, 0); while (Serials.Contains(NewID)) { Gen.NextBytes(Buffer); NewID = BitConverter.ToUInt64(Buffer, 0); } Serials.Add(NewID); base.Session.Add("ID", NewID); SessionID = NewID; Sessions.Add(SessionID, new UserSession(SessionID)); } } } /// <summary> /// Current User Session ID /// </summary> public ulong SessionID; /// <summary> /// Current User Session /// </summary> public UserSession Session { get { return Sessions[SessionID]; } set { Sessions[SessionID] = value; } } /// <summary> /// Kill Current Session ID /// </summary> public void KillSession() { if (Sessions.ContainsKey(SessionID)) { Sessions[SessionID].OnRemove(); Sessions.Remove(SessionID); } base.Session.Remove("ID"); if (Serials.Contains(SessionID)) Serials.Remove(SessionID); } PHP:
you could use sessions but also you could just say on the submit/click event if the page posts back to the same page and you don't forward to a particular page just take textbox1.text (i'm assuming name textbox) and say something like "welcome"+textbox1.text