1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Displaying a welcome message based on a specific user

Discussion in 'C#' started by Nagglfar, Oct 27, 2008.

  1. #1
    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?
    SEMrush
     
    Nagglfar, Oct 27, 2008 IP
    SEMrush
  2. hansab

    hansab Active Member

    Messages:
    162
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #2
    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.
     
    hansab, Oct 27, 2008 IP
  3. ranabra

    ranabra Peon

    Messages:
    125
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    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"
     
    ranabra, Oct 27, 2008 IP
  4. wren

    wren Guest

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    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:
     
    wren, Oct 30, 2008 IP
  5. propstm

    propstm Peon

    Messages:
    286
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #5
    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
     
    propstm, Oct 30, 2008 IP