473,382 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

ASP Session variable problem ...

PM
I'm trying to make a kind of search history containing the 3 last
searched words. So I'm using 3 Session Variables: Word1 / Word2 /
Word3.

In order to get this history working, I need to put the last searched
word in the following Variable.

Ex.:
Session("Word3") = Session("Word2")
Session("Word2") = Session("Word1")
Session("Word1") = Request.QueryString("WORDS")

That way, Word1 is equal to the last searched word, Word2 is equal to
the last value contained in Word1 and Word3 is equal to the last value
contained in Word2.

So, if I search those words in order: carot, orange, apple, rabbit; it
should end up like this:

Word1 = "carot"
Word2 = ""
Word3 = ""

=========

Word1 = "orange"
Word2 = "carot"
Word3 = ""

=========

Word1 = "apple"
Word2 = "orange"
Word3 = "carot"

=========

Word1 = "rabbit"
Word2 = "apple"
Word3 = "orange"

=========

**************************
But instead of this I get:

Word1 = "carot"
Word2 = ""
Word3 = ""

=========

Word1 = "orange"
Word2 = "carot"
Word3 = "carot"

=========

Word1 = "apple"
Word2 = "orange"
Word3 = "orange"

=========

Word1 = "rabbit"
Word2 = "apple"
Word3 = "apple"

=========

I can't explain what is happening!?
Please, can somebody help me!
Thanks a lot!

** and sorry if my english isn't very good ...
Jul 19 '05 #1
3 3526
Is your "Ex." your actual code? That should work. Try this to see:
<%
Session("Word3") = Session("Word2")
Session("Word2") = Session("Word1")
Session("Word1") = Request.FORM("WORDS")
%>

<form method=post>
<input name="words">
<input type=submit>
</form>

<%
response.write "1: " & session("word1") & "<br>" & "2: " &
session("word2") & "<br>" & "3: " & session("word3")
%>

Ray at work

"PM" <pi***********@lanec.com> wrote in message
news:78**************************@posting.google.c om...
I'm trying to make a kind of search history containing the 3 last
searched words. So I'm using 3 Session Variables: Word1 / Word2 /
Word3.

In order to get this history working, I need to put the last searched
word in the following Variable.

Ex.:
Session("Word3") = Session("Word2")
Session("Word2") = Session("Word1")
Session("Word1") = Request.QueryString("WORDS")

That way, Word1 is equal to the last searched word, Word2 is equal to
the last value contained in Word1 and Word3 is equal to the last value
contained in Word2.

So, if I search those words in order: carot, orange, apple, rabbit; it
should end up like this:

Word1 = "carot"
Word2 = ""
Word3 = ""

=========

Word1 = "orange"
Word2 = "carot"
Word3 = ""

=========

Word1 = "apple"
Word2 = "orange"
Word3 = "carot"

=========

Word1 = "rabbit"
Word2 = "apple"
Word3 = "orange"

=========

**************************
But instead of this I get:

Word1 = "carot"
Word2 = ""
Word3 = ""

=========

Word1 = "orange"
Word2 = "carot"
Word3 = "carot"

=========

Word1 = "apple"
Word2 = "orange"
Word3 = "orange"

=========

Word1 = "rabbit"
Word2 = "apple"
Word3 = "apple"

=========

I can't explain what is happening!?
Please, can somebody help me!
Thanks a lot!

** and sorry if my english isn't very good ...

Jul 19 '05 #2
can you cut and paste your code so we can see it. It looks like word3 =
word1

John,

"PM" <pi***********@lanec.com> wrote in message
news:78**************************@posting.google.c om...
I'm trying to make a kind of search history containing the 3 last
searched words. So I'm using 3 Session Variables: Word1 / Word2 /
Word3.

In order to get this history working, I need to put the last searched
word in the following Variable.

Ex.:
Session("Word3") = Session("Word2")
Session("Word2") = Session("Word1")
Session("Word1") = Request.QueryString("WORDS")

That way, Word1 is equal to the last searched word, Word2 is equal to
the last value contained in Word1 and Word3 is equal to the last value
contained in Word2.

So, if I search those words in order: carot, orange, apple, rabbit; it
should end up like this:

Word1 = "carot"
Word2 = ""
Word3 = ""

=========

Word1 = "orange"
Word2 = "carot"
Word3 = ""

=========

Word1 = "apple"
Word2 = "orange"
Word3 = "carot"

=========

Word1 = "rabbit"
Word2 = "apple"
Word3 = "orange"

=========

**************************
But instead of this I get:

Word1 = "carot"
Word2 = ""
Word3 = ""

=========

Word1 = "orange"
Word2 = "carot"
Word3 = "carot"

=========

Word1 = "apple"
Word2 = "orange"
Word3 = "orange"

=========

Word1 = "rabbit"
Word2 = "apple"
Word3 = "apple"

=========

I can't explain what is happening!?
Please, can somebody help me!
Thanks a lot!

** and sorry if my english isn't very good ...

Jul 19 '05 #3
I i'm PM ...

I can't give you all my code here's what I can show you... anything else
does not effect thi section anyway...

Take note that "Word" is replaced by "mot", "mot" is french for "Word".
The QueryString "block" is only a flag that I use to say either I change
my session variables or not. The only time I change the those variables
is when I submit my form. Don't worry!, there is a form in my page, a
textfield named mots and a button used to submit it.

--- Befrore HTML ---
If (Not(Request.Cookies("mot1") Is Nothing)) And (Session("mot1") Is
Nothing) Then Session("mot1") = Request.Cookies("mot1").value
If (Not(Request.Cookies("mot2") Is Nothing)) And (Session("mot2") Is
Nothing) Then Session("mot2") = Request.Cookies("mot2").value
If (Not(Request.Cookies("mot3") Is Nothing)) And (Session("mot3") Is
Nothing) Then Session("mot3") = Request.Cookies("mot3").value

If Request.QueryString("block") <> "1" Then
If Trim(Request.QueryString("mots")) <> "" Then
Session("mot3") = Session("mot2")
Session("mot2") = Session("mot1")
Session("mot1") = Request.QueryString("mots")
End If
End If

--- IN HTML ---
<TABLE width="200" cellspacing="0" cellpadding="0" border="0"
bgcolor="<%=CLR_PNL_ROW1%>" style="border-left:1px solid
<%=CLR_PNL_END%>;border-bottom:1px solid <%=CLR_PNL_END%>;padding:4px">
<TR>
<TD class="main_texte"><img src="image/icon/icn_recherche.gif"
align="absmiddle" border="0">&nbsp;<b>Recherche</b></TD>
</TR>
<TR>
<TD>&nbsp;<asp:textbox class="inpbiblio" style="width:120px"
id="mots" RunAt="Server"/>&nbsp;<asp:button class="button"
ID="rechercher" Text="OK" OnClick="recherche_click"
RunAt="server"/></TD>
</TR>
<% If (Session("mot1") <> "") Then
Response.Cookies("mot1").value = Session("mot1")
Response.Cookies("mot1").expires = datetime.Now.AddDays(365)
%>
<TR>
<TD class="main_texte">&nbsp;<%=IMG_PNL_FLECHE%>&nbsp; <A
href="index.aspx?page=8&module=1&block=1&mots=<%=S ession("mot1")%>"><%=S
ession("mot1")%></A></TD>
</TR>
<% End If %>
<% If (Session("mot2") <> "") Then
Response.Cookies("mot2").value = Session("mot2")
Response.Cookies("mot2").expires = datetime.Now.AddDays(365)
%>
<TR>
<TD class="main_texte">&nbsp;<%=IMG_PNL_FLECHE%>&nbsp; <A
href="index.aspx?page=8&module=1&block=1&mots=<%=S ession("mot2")%>"><%=S
ession("mot2")%></A></TD>
</TR>
<% End If %>
<% If (Session("mot3") <> "") Then
Response.Cookies("mot3").value = Session("mot3")
Response.Cookies("mot3").expires = datetime.Now.AddDays(365)
%>
<TR>
<TD class="main_texte">&nbsp;<%=IMG_PNL_FLECHE%>&nbsp; <A
href="index.aspx?page=8&module=1&block=1&mots=<%=S ession("mot3")%>"><%=S
ession("mot3")%></A></TD>
</TR>
<TR>
<TD><img src="image/trans.gif" width="20" height="1"></TD>
</TR>
<% End If %>
</TABLE>

************************************************

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: doltharz | last post by:
Please Help me i'm doing something i though was to be REALLY EASY but it drives me crazy The complete code is at the end of the email (i mean newsgroup article), i always use Option...
1
by: Ann Leland | last post by:
I have been using session variables to pass a user name from one ASP page to another inside framesets for 9 months and it stopped working this week. I have made no code changes but there was a...
2
by: Eric | last post by:
Hi, I've a problem with trying to retrieve a session variable in an include file. Basically, the main asp creates a session variable: <% Session("var1") = "Hello" %> And then when I click...
4
by: VB Programmer | last post by:
If I have a variable I want to share in my application what is the difference between just declaring a variable (Dim strMyVar as String) and using a session variable (Session("strMyVar"))? When...
9
by: William LaMartin | last post by:
I have a problem, mentioned here before, of Session and Application variables disappearing at one site but not at others or on my development computer. The problem is illustrated by an example...
9
by: Greg Linwood | last post by:
I'm having difficulty understanding Session state in ASP.Net. It's almost embarrassing asking this as I've been using ASP since it was first released & it really shouldn't be this hard to use -...
4
by: T Ralya | last post by:
I am told that ASP.NET controls the session ID and session variables, but that does not fit my symptoms. I am posting here as directed. I'm hoping that someone can at least recommend something to...
3
by: Alan Wang | last post by:
Hi there, Once my application gets complicated and complicated. I found it's really hard to keep track of Session value I am using in my asp.net application. I am just wondering if anyone have...
4
by: Don Miller | last post by:
I am using a Session variable to hold a class object between ASP.NET pages (in VB). In my constructor I check to see if the Session variable exists, and if it doesn't, I create one and populate it...
17
by: Control Freq | last post by:
Hi, Not sure if this is the right NG for this, but, is there a convention for the variable names of a Session variable? I am using .NET 2.0 in C#. I am new to all this .NET stuff, So, any...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.