PDA

View Full Version : Message depending on session variable


gazzaca
06-26-2003, 11:38 PM
I use a shopping cart system that stores the shoppers firstname in a session variable called "firstname"after they register or login to my site.

I need to have different messages displayed on my default.asp depending on if they have logged in or not.

IE: If they have not logged in display "you are not logged in" and provide a link to my registration/login page and "welcome to my site "firstname" and remove the link if they are logged in.

I used " Welcome to our site <%Response.Write(Session("firstname"))%> " this works but slows the site to a crawl

Thanks in advance for any help
Gary

Bullschmidt
06-27-2003, 12:44 AM
You could do something like this:

<% If Session("firstname") = "" Then %>
[HTML stuff for if not logged in]
<% Else %>
Welcome to our site <%= Session("firstname") %>
<% End If %>

gazzaca
06-27-2003, 10:50 AM
Thanks 4 the help, it works, but the only problem is it slows down my site to a crawl, any ideas y it would slow down?

webster252003
06-29-2003, 02:52 AM
Originally posted by gazzaca
Thanks 4 the help, it works, but the only problem is it slows down my site to a crawl, any ideas y it would slow down?

Your code might have somthing to do with it!

It could also be a junck server. Or your connection. Any of those three.

Look for your code and make sure tha you close and/or destroy all objects that you have created. A good rule of thumb is to aquire objects late and release early. This will increase the performace and speed. If you have a lot of HTML and ASP it could also be beacuse the ASP.DLL has to keep swiching from HTML and ASP and it get bogged down. TO correct this you need to cut down on <%=%> if you are using this. If is a good idea to block your code istead of all over. Remove youtr whitespace. Get rid of all that extraspace. Not only does this take longer to process it actually takes up for bandwidth. If you are on a shared server it could be that other users on that server are not following good server performance and will more than likely to be shut down in a while. In the mean time try to cut back on what you use and don't add to the problem.

Whitesword
06-29-2003, 09:22 AM
Ummm.. have you though of just writing

" Welcome to our site <%=Session("firstname")%> "

It does exactly the same thing as the response write but the asp engine doesn't have to invoke the reponse.write object.

Just my 2c worth...

webster252003
06-29-2003, 08:36 PM
Originally posted by Whitesword
Ummm.. have you though of just writing

" Welcome to our site <%=Session("firstname")%> "

It does exactly the same thing as the response write but the asp engine doesn't have to invoke the reponse.write object.

Just my 2c worth...

This is wrong. ASP engine replaces this with Response.Write just before processing.