473,699 Members | 3,103 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.QuerySt ring("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 3536
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("W ORDS")
%>

<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.goo gle.com...
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.QuerySt ring("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.goo gle.com...
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.QuerySt ring("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.Co okies("mot1") Is Nothing)) And (Session("mot1" ) Is
Nothing) Then Session("mot1") = Request.Cookies ("mot1").val ue
If (Not(Request.Co okies("mot2") Is Nothing)) And (Session("mot2" ) Is
Nothing) Then Session("mot2") = Request.Cookies ("mot2").val ue
If (Not(Request.Co okies("mot3") Is Nothing)) And (Session("mot3" ) Is
Nothing) Then Session("mot3") = Request.Cookies ("mot3").val ue

If Request.QuerySt ring("block") <> "1" Then
If Trim(Request.Qu eryString("mots ")) <> "" Then
Session("mot3") = Session("mot2")
Session("mot2") = Session("mot1")
Session("mot1") = Request.QuerySt ring("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_tex te"><img src="image/icon/icn_recherche.g if"
align="absmiddl e" border="0">&nbs p;<b>Recherche</b></TD>
</TR>
<TR>
<TD>&nbsp;<asp: textbox class="inpbibli o" style="width:12 0px"
id="mots" RunAt="Server"/>&nbsp;<asp:but ton class="button"
ID="rechercher " Text="OK" OnClick="recher che_click"
RunAt="server"/></TD>
</TR>
<% If (Session("mot1" ) <> "") Then
Response.Cookie s("mot1").val ue = Session("mot1")
Response.Cookie s("mot1").expir es = datetime.Now.Ad dDays(365)
%>
<TR>
<TD class="main_tex te">&nbsp;<%=IM G_PNL_FLECHE%>& nbsp;<A
href="index.asp x?page=8&module =1&block=1&mots =<%=Session("mo t1")%>"><%=S
ession("mot1")% ></A></TD>
</TR>
<% End If %>
<% If (Session("mot2" ) <> "") Then
Response.Cookie s("mot2").val ue = Session("mot2")
Response.Cookie s("mot2").expir es = datetime.Now.Ad dDays(365)
%>
<TR>
<TD class="main_tex te">&nbsp;<%=IM G_PNL_FLECHE%>& nbsp;<A
href="index.asp x?page=8&module =1&block=1&mots =<%=Session("mo t2")%>"><%=S
ession("mot2")% ></A></TD>
</TR>
<% End If %>
<% If (Session("mot3" ) <> "") Then
Response.Cookie s("mot3").val ue = Session("mot3")
Response.Cookie s("mot3").expir es = datetime.Now.Ad dDays(365)
%>
<TR>
<TD class="main_tex te">&nbsp;<%=IM G_PNL_FLECHE%>& nbsp;<A
href="index.asp x?page=8&module =1&block=1&mots =<%=Session("mo t3")%>"><%=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
3345
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 Explicit and Response.Expires=-1,
1
3108
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 "security update" installed on the server a few days ago but I can't find out exactly what it was. In the research I have done I found many articles on the subject of session variables in ASP pages inside framesets. From what I read a new...
2
13553
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 on a button it refers to the include file, which I believe is all client-side code as there are no server <% %> tags.
4
1651
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 should I use a session variable and when should I just declare it like normal? Thanks in advance!
9
2450
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 at http://www.lamartin.com/dotnet/sessiontestset.aspx, were I set Session, Application and Cache variables on the first page and then on the second page view them as the second page is refreshed every five seconds. Before 10 refreshes, the...
9
2383
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 - perhaps I'm just not very smart or perhaps MS is making this too hard for us sql bunnies to understand - I dunno, but I'd really appreciate someone explaining what I'm doing wrong here & perhaps suggest a better approach.. I'm familiar with use of...
4
1949
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 try to isolate the problem. I have a simple application that demonstrates my problem. Page 1, step1: SaveSessionVariableButton will create a string value, show it on screen, save it in a session variable and show the session ID on screen....
3
2908
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 any experience on how to keep track of session value. Any help it's appreciated. Thanks Alan
4
3439
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 with "Me". But if the Session variable already exists, I would like the new object be populated with everything from the object stored in the Session variable. Ideally, I'd like to retrieve the object from the Session variable and assign it to...
17
5088
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 guidance appreciated. Regards
1
8936
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8894
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7776
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5879
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4390
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3071
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2360
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.