Old 04-03-2008, 13:47   #1 (permalink)
robert475
Registered User
 
Join Date: Feb 2006
Posts: 30
Session with two values

Hi there i know this is a daft question but i have been playing with this block of code and know i am missing something really simple.

I have created a two sessions - (tf4) (tf5).

I want tf4 to store a value which is simple to do no problems. But if session-tf4 already has a value stored in it then i would like tf5 to capture the value. I have tried to do this with an if statement but both the sessions get populated with exactly the same value each time i run through the application.

The code is like this:

<%
Session("keycode") = Request( "keycode")
%>
<%
Session("tf4") = Request( "keycode")
%>
<%
if Session("tf4") <> "" or Session("tf4") = Session("Keycode") then
session("tf5") = session("keycode")
Else
Session("tf4") = Session("Keycode")
end if
%>


So I will only need session tf5 if tf4 has a value stored in it. Any suggestions on what i could do? Do apologise about the silly question, thanks.
  Reply With Quote
Old 04-03-2008, 18:55   #2 (permalink)
haku
shiro
 
haku's Avatar
 
Join Date: Aug 2007
Location: Yokohama, Japan
Posts: 1,659
I dont know ASP, so I cant show you code, but in theory it should be this:

Code:
if tf4 is not empty{ tf5 = something }

Maybe you can work with that theory.
  Reply With Quote
Old 05-03-2008, 04:14   #3 (permalink)
woodss
Just another web monkey
 
woodss's Avatar
 
Join Date: Mar 2005
Location: Newcastle, UK
Posts: 216
Send a message via ICQ to woodss Send a message via MSN to woodss Send a message via Yahoo to woodss Send a message via Skype™ to woodss
Remember that sessions persist across page refreshes - if you want to test this is working properly, stick:
Code:
Session.Abandon()
before it all, and that will clear any previous runs.

Try this:
Code:
strTemp = Request.Form("KeyCode") Session("TF4") = strTemp If Not IsNull(Session("TF4")) And Session("TF4") <> "" Then 'Session TF4 has a value Session("TF5") = Session("TF4") Else 'Session TF4 had no value End If

Hope this helps but I get the impression you're trying to do something the wrong way lol
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8