Showing posts with label pages. Show all posts
Showing posts with label pages. Show all posts

Saturday, March 31, 2012

Session tracked via URL in ASP.NET

Hello,

I have my asp.net web application to track session id across pages using the url, and not cookies, ie in the web.config file:
<sessionState .... cookieless="true" ...... />

however each link in the page does not embed the id in the url like it is supposed to :

<a href="http://links.10026.com/?link=http://mywebserver/(rqe4ptb333ojxz3kh1t3xqr3)/mypage.aspx"> my link </a>

and so each page i travel to, a new session id is created in the url and the information associated with the previous page's session id is lost.

can anybody tell me what else i need to do to make this work?

thank you,

Kenton Taylorfor some reason the .net framework will not insert the session id before rendering the HTML if your HREF uses a "/" to denote that the path is relative to the root

this will work:
href="http://myserver/home.aspx"

as will this:
href="home.aspx"

but this won't:
href="/home.aspx"

Thursday, March 29, 2012

session variable

Hi all
I'm newbie to asp.net and building simple pages using vb.net.
I have got three pages default.aspx (which is login page), index.aspx and logout.aspx.

In logout.aspx i have put following code...
Session.Clear()

Session.RemoveAll()

Session.Abandon()

Response.Redirect("default.aspx")

In Index.aspx I have following code in page load event..

If Session("login") = "" Then 'this session variable is created from default.aspx on successful login which store user login name

Response.Redirect("default.aspx")

End If

But somehow after hitting logout link from index.aspx it still keeps session("login") value though it redirect to default.aspx..

After tht if i try to execute page directly index.aspx (on same browser window), the page index.aspx is displayed..(which is basically should not be displayed.) ...When I hit refresh it redirects to default.aspx but url remains the same with index.aspx

Below is web.config snippet...

<sessionState

mode="InProc"

stateConnectionString="tcpip=127.0.0.1:42424"

sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"

cookieless="false"

timeout="20"

/
Anyone has any clue why its happening like this??

Any help would be appreciated..

Thanx in advance

daveA couple comments. First off, you might save yourself a handful of lines of code as well as this problem if you used the built-in FormsAuthentication:
http://www.15seconds.com/issue/020220.htm
http://www.15seconds.com/issue/020305.htm

I suspect they are getting to index.aspx because the page is cached...hence when they force a refresh they are being logged out. You might want to look at :
http://www.15seconds.com/issue/010202.htm
which will tell you how to make sure the browser doesn't cache the page.

As for why ur session doesn't clear, you might wanna try Response.Redirect("default.aspx", false) If that works check out :
http://weblogs.asp.net/bleroy/archi.../03/207486.aspx for why...not sure if that applies to clearing session though, don't think so.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to come!)

"dave" <nojunk@.nojunk.com> wrote in message news:ONMZBDbvFHA.2072@.TK2MSFTNGP14.phx.gbl...
Hi all
I'm newbie to asp.net and building simple pages using vb.net.
I have got three pages default.aspx (which is login page), index.aspx and logout.aspx.

In logout.aspx i have put following code...
Session.Clear()

Session.RemoveAll()

Session.Abandon()

Response.Redirect("default.aspx")

In Index.aspx I have following code in page load event..

If Session("login") = "" Then 'this session variable is created from default.aspx on successful login which store user login name

Response.Redirect("default.aspx")

End If

But somehow after hitting logout link from index.aspx it still keeps session("login") value though it redirect to default.aspx..

After tht if i try to execute page directly index.aspx (on same browser window), the page index.aspx is displayed..(which is basically should not be displayed.) ...When I hit refresh it redirects to default.aspx but url remains the same with index.aspx

Below is web.config snippet...

<sessionState

mode="InProc"

stateConnectionString="tcpip=127.0.0.1:42424"

sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"

cookieless="false"

timeout="20"

/
Anyone has any clue why its happening like this??

Any help would be appreciated..

Thanx in advance

dave
"dave" <nojunk@.nojunk.com> wrote in message news:ONMZBDbvFHA.2072@.TK2MSFTNGP14.phx.gbl...
Hi all
I'm newbie to asp.net and building simple pages using vb.net.
I have got three pages default.aspx (which is login page), index.aspx and logout.aspx.

In logout.aspx i have put following code...
Session.Clear()

Session.RemoveAll()

Session.Abandon()

Response.Redirect("default.aspx")

In Index.aspx I have following code in page load event..

If Session("login") = "" Then 'this session variable is created from default.aspx on successful login which store user login name

Response.Redirect("default.aspx")

End If

In C# I would not check for an empty string, but for null. In VB you might need to
check for "Nothing".
You don't store "strings" in Session, you store "objects". A string is a perfectly
valid object, so you can store it without problems. But if the Session variable
has been removed, it's *removed* (not there, nothing), not an empty string.
But somehow after hitting logout link from index.aspx it still keeps session("login") value though it redirect to default.aspx..

After tht if i try to execute page directly index.aspx (on same browser window), the page index.aspx is displayed..(which is basically should not be displayed.) ...When I hit refresh it redirects to default.aspx but url remains the same with index.aspx

If you use Redirect, you instruct the browser to go to a different URL, so that other
URL should be displayed (If you had used Transfer, this would not be the case, as that
works entirely server-side). So you are not "redirected" to default.aspx, but something else
happened.

Hans Kesting

session variable

Hi all
I'm newbie to asp.net and building simple pages using vb.net.
I have got three pages default.aspx (which is login page), index.aspx and lo
gout.aspx.
In logout.aspx i have put following code...
Session.Clear()
Session.RemoveAll()
Session.Abandon()
Response.Redirect("default.aspx")
In Index.aspx I have following code in page load event..
If Session("login") = "" Then 'this session variable is created from default
.aspx on successful login which store user login name
Response.Redirect("default.aspx")
End If
But somehow after hitting logout link from index.aspx it still keeps session
("login") value though it redirect to default.aspx..
After tht if i try to execute page directly index.aspx (on same browser wind
ow), the page index.aspx is displayed..(which is basically should not be dis
played.) ...When I hit refresh it redirects to default.aspx but url remains
the same with index.aspx
Below is web.config snippet...
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="20"
/>
Anyone has any clue why its happening like this'
Any help would be appreciated..
Thanx in advance
daveA couple comments. First off, you might save yourself a handful of lines of
code as well as this problem if you used the built-in FormsAuthentication:
http://www.15seconds.com/issue/020220.htm
http://www.15seconds.com/issue/020305.htm
I suspect they are getting to index.aspx because the page is cached...hence
when they force a refresh they are being logged out. You might want to look
at :
http://www.15seconds.com/issue/010202.htm
which will tell you how to make sure the browser doesn't cache the page.
As for why ur session doesn't clear, you might wanna try Response.Redirect("
default.aspx", false) If that works check out :
http://weblogs.asp.net/bleroy/archi.../03/207486.aspx for why...not
sure if that applies to clearing session though, don't think so.
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to come!
)
"dave" <nojunk@.nojunk.com> wrote in message news:ONMZBDbvFHA.2072@.TK2MSFTNGP
14.phx.gbl...
Hi all
I'm newbie to asp.net and building simple pages using vb.net.
I have got three pages default.aspx (which is login page), index.aspx and lo
gout.aspx.
In logout.aspx i have put following code...
Session.Clear()
Session.RemoveAll()
Session.Abandon()
Response.Redirect("default.aspx")
In Index.aspx I have following code in page load event..
If Session("login") = "" Then 'this session variable is created from default
.aspx on successful login which store user login name
Response.Redirect("default.aspx")
End If
But somehow after hitting logout link from index.aspx it still keeps session
("login") value though it redirect to default.aspx..
After tht if i try to execute page directly index.aspx (on same browser wind
ow), the page index.aspx is displayed..(which is basically should not be dis
played.) ...When I hit refresh it redirects to default.aspx but url remains
the same with index.aspx
Below is web.config snippet...
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="20"
/>
Anyone has any clue why its happening like this'
Any help would be appreciated..
Thanx in advance
dave
"dave" <nojunk@.nojunk.com> wrote in message news:ONMZBDbvFHA.2072@.TK2MSFTNGP
14.phx.gbl...
Hi all
I'm newbie to asp.net and building simple pages using vb.net.
I have got three pages default.aspx (which is login page), index.aspx and lo
gout.aspx.
In logout.aspx i have put following code...
Session.Clear()
Session.RemoveAll()
Session.Abandon()
Response.Redirect("default.aspx")
In Index.aspx I have following code in page load event..
If Session("login") = "" Then 'this session variable is created from default
.aspx on successful login which store user login name
Response.Redirect("default.aspx")
End If
In C# I would not check for an empty string, but for null. In VB you might n
eed to
check for "Nothing".
You don't store "strings" in Session, you store "objects". A string is a per
fectly
valid object, so you can store it without problems. But if the Session varia
ble
has been removed, it's *removed* (not there, nothing), not an empty string.
But somehow after hitting logout link from index.aspx it still keeps session
("login") value though it redirect to default.aspx..
After tht if i try to execute page directly index.aspx (on same browser wind
ow), the page index.aspx is displayed..(which is basically should not be dis
played.) ...When I hit refresh it redirects to default.aspx but url remains
the same with index.aspx
If you use Redirect, you instruct the browser to go to a different URL, so t
hat other
URL should be displayed (If you had used Transfer, this would not be the cas
e, as that
works entirely server-side). So you are not "redirected" to default.aspx, bu
t something else
happened.
Hans Kesting

Session variable and Back

I am using a session variable to store a value that added when a person goes through multiple pages on a form, basically a scorecard. If the person hits the Back button to redo a value, how do I restore the original value before they hit submit again? Right now the old value and the new value are being added together.

thanks

You need to "disable" the browser's Back button's functionality so that it does not load the page from the browser cache but hits the same page again. See this post for details:

http://geekswithblogs.net/vivek/archive/2007/02/24/107148.aspx

So whenever user presses back button the page_load event will fire again and you can put the relevant session setting/modifying code there.

Hope this helps,

Vivek


You could store the value to be passed in a hidden form input. That way the value will always be what it was when the page was posted.

Monday, March 26, 2012

Session Variable dissappears between post backs on Win 2003

I have a problem with a Session variable that dissapears after a
postback of one of my pages.
This only happens on WIn 2003 servers.. it is fine on my XP dev box.
This page opens in another window, but I have ascertained that is is
definitely using the same session ID.
Nowhere on the page do I clear the session variable.. it is only ever
retrieved... this page only works if it is there.
Has anyone had as similar problem? Any help gratefully received!
Dirc
--Is the Windows 2003 server (you say servers which leads me to ask this) part
of a webfarm? You may be losing sessions as you are moved from one server to
another. If this is a the case one way to fix this would be to store session
state on the SQL Server, if you're using one.
Here's an article on how to move session state to the SQL Server. It's easy
to do and has some other benefits such as users not losing their sessions
even if a server in the farm needs to be restarted, etc.
http://idunno.org/dotNet/sessionState.aspx
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"Dirc Khan-Evans" <dirc.khan-evans@.eurorscgskybridge.com> wrote in message
news:uTgSjp$0FHA.3376@.TK2MSFTNGP14.phx.gbl...
> I have a problem with a Session variable that dissapears after a
> postback of one of my pages.
> This only happens on WIn 2003 servers.. it is fine on my XP dev box.
> This page opens in another window, but I have ascertained that is is
> definitely using the same session ID.
> Nowhere on the page do I clear the session variable.. it is only ever
> retrieved... this page only works if it is there.
> Has anyone had as similar problem? Any help gratefully received!
> Dirc
> --
>
No, no, no..
I mean in multiple environments.. dev, testing and live.
BTW, I have also tried using StateServer, since I have been told it is
more reliable.. but something as simple as this should not happen on a
lightly used test server!
Dirc,
Ok, I didn't realize you meant between multiple environments. So, you've
already stated that this is not hapenning on your development box. Is it
happening on the testing and production servers both? Are other developers
deploying code to the testing or production servers at the same time?
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"Dirc Khan-Evans" <dirc.khan-evans@.eurorscgskybridge.com> wrote in message
news:%23SNpu5$0FHA.3924@.TK2MSFTNGP14.phx.gbl...
> No, no, no..
> I mean in multiple environments.. dev, testing and live.
> BTW, I have also tried using StateServer, since I have been told it is
> more reliable.. but something as simple as this should not happen on a
> lightly used test server!
> --
>
S. Justin Gengo wrote:

> Dirc,
> Ok, I didn't realize you meant between multiple environments. So,
> you've already stated that this is not hapenning on your development
> box. Is it happening on the testing and production servers both? Are
> other developers deploying code to the testing or production servers
> at the same time?
No.. I am the only one changing anything in the bin folder... I know
where you are coming from.. There are no changes going on that would
cause an IIS restart.
To reiterate: The interesting things to note is that
(a) it always happens with this page.. it is in no way an intermittent
problem,
(b) this only happens when the new page is displayed in another window.
The first page loads fine but after that the session variable totally
dissappears for no apparent reason.. there is no explicit removal of
any Session variables in the code.
(c) It only happens on IIS6/ win 20003 servers. Not XP
(d) The session has the same sessionID for both windows (as expected).
This really smells of a bug to me....
Dirc
Dirc,
Ok, here's a test to try. In the first window create a button that, when
clicked, response.writes the session variable to the page.
Open the page and click the button to confirm the session variable is there.
Then open your second page. Click the first page's session variable button
again to see if the session variable has disappeared. I'm wondering if the
pop-up window is somehow using a different session.
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"Dirc Khan-Evans" <dirc.khan-evans@.[no_spam_please]eurorscgskybridge.com>
wrote in message news:ODVldSI1FHA.1252@.TK2MSFTNGP09.phx.gbl...
> S. Justin Gengo wrote:
>
> No.. I am the only one changing anything in the bin folder... I know
> where you are coming from.. There are no changes going on that would
> cause an IIS restart.
> To reiterate: The interesting things to note is that
> (a) it always happens with this page.. it is in no way an intermittent
> problem,
> (b) this only happens when the new page is displayed in another window.
> The first page loads fine but after that the session variable totally
> dissappears for no apparent reason.. there is no explicit removal of
> any Session variables in the code.
> (c) It only happens on IIS6/ win 20003 servers. Not XP
> (d) The session has the same sessionID for both windows (as expected).
> This really smells of a bug to me....
> Dirc
> --
>
Do you have anti-virus software running? You stated that you are the
only one changing the bin folder...but if you have anti-virus software
running it could be touching the bin folder. We had the same problem
with session and disabling the anti-virus s/w fixed the problem.
Rosanne
---
Rosanne's Profile: http://www.highdots.com/forums/m283
View this thread: http://www.highdots.com/forums/t3035507

Session Variable dissappears between post backs on Win 2003

I have a problem with a Session variable that dissapears after a
postback of one of my pages.

This only happens on WIn 2003 servers.. it is fine on my XP dev box.

This page opens in another window, but I have ascertained that is is
definitely using the same session ID.

Nowhere on the page do I clear the session variable.. it is only ever
retrieved... this page only works if it is there.

Has anyone had as similar problem? Any help gratefully received!

Dirc
--Is the Windows 2003 server (you say servers which leads me to ask this) part
of a webfarm? You may be losing sessions as you are moved from one server to
another. If this is a the case one way to fix this would be to store session
state on the SQL Server, if you're using one.

Here's an article on how to move session state to the SQL Server. It's easy
to do and has some other benefits such as users not losing their sessions
even if a server in the farm needs to be restarted, etc.

http://idunno.org/dotNet/sessionState.aspx

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Dirc Khan-Evans" <dirc.khan-evans@.eurorscgskybridge.com> wrote in message
news:uTgSjp$0FHA.3376@.TK2MSFTNGP14.phx.gbl...
> I have a problem with a Session variable that dissapears after a
> postback of one of my pages.
> This only happens on WIn 2003 servers.. it is fine on my XP dev box.
> This page opens in another window, but I have ascertained that is is
> definitely using the same session ID.
> Nowhere on the page do I clear the session variable.. it is only ever
> retrieved... this page only works if it is there.
> Has anyone had as similar problem? Any help gratefully received!
> Dirc
> --
No, no, no..

I mean in multiple environments.. dev, testing and live.

BTW, I have also tried using StateServer, since I have been told it is
more reliable.. but something as simple as this should not happen on a
lightly used test server!

--
Dirc,

Ok, I didn't realize you meant between multiple environments. So, you've
already stated that this is not hapenning on your development box. Is it
happening on the testing and production servers both? Are other developers
deploying code to the testing or production servers at the same time?

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Dirc Khan-Evans" <dirc.khan-evans@.eurorscgskybridge.com> wrote in message
news:%23SNpu5$0FHA.3924@.TK2MSFTNGP14.phx.gbl...
> No, no, no..
> I mean in multiple environments.. dev, testing and live.
> BTW, I have also tried using StateServer, since I have been told it is
> more reliable.. but something as simple as this should not happen on a
> lightly used test server!
> --
S. Justin Gengo wrote:

> Dirc,
> Ok, I didn't realize you meant between multiple environments. So,
> you've already stated that this is not hapenning on your development
> box. Is it happening on the testing and production servers both? Are
> other developers deploying code to the testing or production servers
> at the same time?

No.. I am the only one changing anything in the bin folder... I know
where you are coming from.. There are no changes going on that would
cause an IIS restart.

To reiterate: The interesting things to note is that
(a) it always happens with this page.. it is in no way an intermittent
problem,
(b) this only happens when the new page is displayed in another window.
The first page loads fine but after that the session variable totally
dissappears for no apparent reason.. there is no explicit removal of
any Session variables in the code.
(c) It only happens on IIS6/ win 20003 servers. Not XP
(d) The session has the same sessionID for both windows (as expected).

This really smells of a bug to me....

Dirc

--
Dirc,

Ok, here's a test to try. In the first window create a button that, when
clicked, response.writes the session variable to the page.

Open the page and click the button to confirm the session variable is there.
Then open your second page. Click the first page's session variable button
again to see if the session variable has disappeared. I'm wondering if the
pop-up window is somehow using a different session.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Dirc Khan-Evans" <dirc.khan-evans@.[no_spam_please]eurorscgskybridge.com>
wrote in message news:ODVldSI1FHA.1252@.TK2MSFTNGP09.phx.gbl...
> S. Justin Gengo wrote:
>> Dirc,
>>
>> Ok, I didn't realize you meant between multiple environments. So,
>> you've already stated that this is not hapenning on your development
>> box. Is it happening on the testing and production servers both? Are
>> other developers deploying code to the testing or production servers
>> at the same time?
> No.. I am the only one changing anything in the bin folder... I know
> where you are coming from.. There are no changes going on that would
> cause an IIS restart.
> To reiterate: The interesting things to note is that
> (a) it always happens with this page.. it is in no way an intermittent
> problem,
> (b) this only happens when the new page is displayed in another window.
> The first page loads fine but after that the session variable totally
> dissappears for no apparent reason.. there is no explicit removal of
> any Session variables in the code.
> (c) It only happens on IIS6/ win 20003 servers. Not XP
> (d) The session has the same sessionID for both windows (as expected).
> This really smells of a bug to me....
> Dirc
> --
Do you have anti-virus software running? You stated that you are the
only one changing the bin folder...but if you have anti-virus software
running it could be touching the bin folder. We had the same problem
with session and disabling the anti-virus s/w fixed the problem.

--
Rosanne
----------------------
Rosanne's Profile: http://www.highdots.com/forums/m283
View this thread: http://www.highdots.com/forums/t3035507

Session Variable Disappeared

Hello,

I'm using MasterPages to create the layout for all of the pages in my project. Before I converted the Default.aspx page over to the masterpage format this worked.

I have two pages, login.aspx and default.aspx, of course I'm using Forms Authentication. All that works fine, you try to get to default it prompts for login.

Well I used a custom function for the login, it compares data entered to that in a database, if it passed it also returns a variable containing there Trust Level. (String)

At the end of the Button Submit Click but before I redirect the authenticated user to the page they requested I use this code to store trust level in the Session object.

Session("Trust")=TRUST

When the default page loads it shows/hides elements base on thier trust. Now after I've switched over to master pages the code no longer works, it's returning an empty string for Session("Trust")

Example:

<% If Session("Trust") = "Admin" Then %>
Your Access Level is Administrator
<% Else %>
Your Access Level is <% Response.Write(Session("Trust")) %>
<% End If %
I'm loggin in with the Admin Account with a trust of "Admin" and it's just returning an empty string.

Any ideas?What are you using to redirect? If you are not currently, you should be using the RedirectFromLoginPage method.

HTH...
CHris
Thx for the reply,

I figured it out, it was because I deleted the Global.* file. D'OH

Session variable details

Good afternoon, I have two pages one is a select movie page the other is a view cart page, the problem is when i select a movie the details do not show up on the view cart page, can someone point me in the right direction please. below is my code;

select movie code;

<%

@dotnet.itags.org.PageLanguage="C#"Debug="true"AutoEventWireup="true"CodeFile="SelectedFilm.cs"Inherits="SelectedFilm "%>

<!

DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<

htmlxmlns="http://www.w3.org/1999/xhtml"xml:lang="en"lang="en">

<

head>

<

metahttp-equiv="Content-Type"content="text/html; charset=iso-8859-1"/>

<

metaname="description"content="Description of your web page goes here."/>

<

metaname="keywords"content="Keywords for you web page go here. Each keyword or group of keyword phrases are separated by a comma. Keep this keyword list short and relevant to the content of this specific page and also relevant to the tile of the specific page."/>

<

title>Movie Stream</title>

<

linkrel="shortcut icon"href="shortcut.jpg"/>

<

linkhref="moviestream.css"rel="stylesheet"type="text/css"/>

<

scriptlanguage="javascript"type="text/javascript">

</

script>

</

head>

<

bodystyle="background-color: #dcdcdc"><formid="form1"runat="server">

<

divid="mainnav-container"><divid="mainnav"><divclass="none"><ahref="#maincontent"></a> </div><ul><li><ahref="layout.aspx"title=""><spanstyle="font-size: 11pt">Home</span></a><spanstyle="font-size: 11pt"> </span></li><li><ahref="#"title=""><spanstyle="font-size: 11pt">Contact</span></a></li><li><ahref="MS_Admin.aspx"title=""><spanstyle="font-size: 11pt">Admin Login</span></a><spanstyle="font-size: 11pt">

<%

-- <li><a href="http://links.10026.com/?link=MS_Admin.aspx" title=""><span style="font-size: 11pt">Admin Login</span></a><span style="font-size: 11pt">

--

%></span></li></ul></div><divid="mainnav-side"><ul><li><ahref="registered_customer.aspx"title=""><spanstyle="font-size: 12pt">Login</span></a><spanstyle="font-size: 12pt"></span></li><li><ahref="new_customer.aspx"title=""><spanstyle="font-size: 12pt">Register</span></a></li></ul></div><divclass="clear"></div>

</

div>

<!--

SITE NAME & SLOGAN

-->

<

divid="header">

<

ahref="layout.aspx"title="Site name home page"></a><divid="slogan"><spanstyle="font-family: Trebuchet MS"><spanstyle="font-size: 12pt">

MOVIE STREAM

<br/></span>

"Delivering movies to your desk top"

</span></div>

</

div>

<

divid="breadcrumb-container"><divid="breadcrumb"><ahref="layout.aspx"title="Users will see this text ">Home</a> /<ahref="#"title="Users will see this text">Breadcrumb link</a> / Page Title</div><divid="breadcrumb-side">

Search <asp:TextBoxid="SearchWord"runat="server"></asp:TextBox> <asp:ButtonID="Button1"runat="server"Text="go"OnClick="Button1_onclick"/>

<%

-- <asp:Button /> id="Button1" type="button" value="Go" language="javascript" onclick="Button1_onclick()" />--%><asp:LabelID="lblMessage"runat="server"Text=""></asp:Label><br/> </div><divclass="clear"></div>

</

div>

<!--

CONTENT

-->

<

divid="content-container"style="background-color: #ffffff"><!--

SIDE COLUMN

-->

<divid="content-side"style="left: 1px"><p><spanstyle="font-size: 14pt; font-family: Trebuchet MS; color: gray;">Genre</span></p><ulclass="link-list-vertical"><li><ahref="MS_Action.aspx"title="Movies to give you an Adrenaline rush."><spanstyle="font-size: 12pt">

Action

</span></a><spanstyle="font-size: 12pt"></span></li><li><ahref="MS_Anime.aspx"title="Animated movies."><spanstyle="font-size: 12pt">Anime</span></a><spanstyle="font-size: 12pt"></span></li><li><ahref="#"title="Movies to make you laugh."><spanstyle="font-size: 12pt">Comedy</span></a><spanstyle="font-size: 12pt"></span></li><li><ahref="#"title="Strong following movies"><spanstyle="font-size: 12pt">Cult</span></a><spanstyle="font-size: 12pt"></span></li><li><ahref="#"title="Facts or fiction."><spanstyle="font-size: 12pt">Documentary</span></a></li><li><spanstyle="font-size: 12pt"></span></li></ul></div><!--

MAIN COLUMN

-->

<divid="content"style="height: 1%"><aname="maincontent"id="maincontent"></a><h1><spanstyle="font-family: Trebuchet MS"></span></h1><br/><br/>

<asp:DataListID="DataList1"runat="server"DataSourceID="SqlDataSource1"OnSelectedIndexChanged="DataList1_SelectedIndexChanged1"><ItemTemplate>

Movie ID:

<asp:LabelID="Movie_IDLabel"runat="server"Text='<%# Eval("Movie_ID") %>'></asp:Label><br/><br/>

Genre Category:

<asp:LabelID="Genre_CategoryLabel"runat="server"Text='<%# Eval("Genre_Category") %>'></asp:Label><br/><br/>

Movie name:

<asp:LabelID="Movie_nameLabel"runat="server"Text='<%# Eval("Movie_name") %>'></asp:Label><br/><br/>

Release date:

<asp:LabelID="Release_dateLabel"runat="server"Text='<%# Eval("Release_date") %>'></asp:Label><br/><br/>

Length:

<asp:LabelID="LengthLabel"runat="server"Text='<%# Eval("Length") %>'></asp:Label><br/><br/>

Synopsis:

<asp:LabelID="SynopsisLabel"runat="server"Text='<%# Eval("Synopsis") %>'></asp:Label><br/><br/>

Starring:

<asp:LabelID="StarringLabel"runat="server"Text='<%# Eval("Starring") %>'></asp:Label><br/><br/>

Director:

<asp:LabelID="DirectorLabel"runat="server"Text='<%# Eval("Director") %>'></asp:Label><br/><br/>

Price:

<asp:LabelID="PriceLabel"runat="server"Text='<%# Eval("Price") %>'></asp:Label><br/><br/>

<asp:ButtonID="addToCartel"runat="server"OnClick="addToCart"Text="Select movie"/><br/></ItemTemplate></asp:DataList><asp:SqlDataSourceID="SqlDataSource1"runat="server"ConnectionString="<%$ ConnectionStrings:movie_streamConnectionString5 %>"SelectCommand="SELECT [Movie_ID], [Genre_Category], [Movie_name], [Release_date], [Length], [Synopsis], [Starring], [Director], [Price] FROM [MS_Movies] WHERE ([Movie_name] = @dotnet.itags.org.Movie_name)"><SelectParameters><asp:QueryStringParameterDefaultValue="Movie_name"Name="Movie_name"QueryStringField="Movie_name"Type="String"/></SelectParameters></asp:SqlDataSource>

<!--

FOOTER

-->

<

divid="footer"><p>

Movie Stream

</p><p>

382 Brent Cross Road.

</p><p>

? 2007 Movie Stream. All rights reserved.

</p>

</

div></div><!--

SIDE 2 COLUMN

-->

<divid="content-side-2"><divclass="listbox"><divclass="header"><spanstyle="font-size: 12pt; font-family: Trebuchet MS; color: #dcdcdc;"><strongstyle="color: gray">New releases</strong></span></div><olclass="listbox"><li><ahref=""><b><spanstyle="font-family: Trebuchet MS; font-size: 10pt;">Deja Vu</span></b></a><spanstyle="font-family: Trebuchet MS"></span></li><li><ahref=""><b><spanstyle="font-family: Trebuchet MS; font-size: 10pt;">Red Eye</span></b></a><spanstyle="font-family: Trebuchet MS; font-size: 10pt;"></span></li><li><ahref=""><b><spanstyle="font-family: Trebuchet MS; font-size: 10pt;">Dodgers</span></b></a><spanstyle="font-family: Trebuchet MS; font-size: 10pt;"></span></li><li><ahref=""><b><spanstyle="font-family: Trebuchet MS; font-size: 10pt;">Basketball diaries</span></b></a><spanstyle="font-family: Trebuchet MS; font-size: 10pt;"></span></li></ol></div></div>

</

div>

</

form>

</

body>

</

html>

<%

-- <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" OnSelectedIndexChanged="DataList1_SelectedIndexChanged1">

<ItemTemplate>

Movie ID:

<asp:Label ID="Movie_IDLabel" runat="server" Text='<%# Eval("Movie_ID") %>'></asp:Label><br />

<br />

Genre Category:

<asp:Label ID="Genre_CategoryLabel" runat="server" Text='<%# Eval("Genre_Category") %>'></asp:Label><br />

<br />

Movie name:

<asp:Label ID="Movie_nameLabel" runat="server" Text='<%# Eval("Movie_name") %>'></asp:Label><br />

<br />

Release date:

<asp:Label ID="Release_dateLabel" runat="server" Text='<%# Eval("Release_date") %>'></asp:Label><br />

<br />

Length:

<asp:Label ID="LengthLabel" runat="server" Text='<%# Eval("Length") %>'></asp:Label><br />

<br />

Synopsis:

<asp:Label ID="SynopsisLabel" runat="server" Text='<%# Eval("Synopsis") %>'></asp:Label><br />

<br />

Starring:

<asp:Label ID="StarringLabel" runat="server" Text='<%# Eval("Starring") %>'></asp:Label><br />

<br />

Director:

<asp:Label ID="DirectorLabel" runat="server" Text='<%# Eval("Director") %>'></asp:Label><br />

<br />

Price:

<asp:Label ID="PriceLabel" runat="server" Text='<%# Eval("Price") %>'></asp:Label><br />

<br />

<asp:Button ID="addToCartie" runat="server" OnClick="addToCart" Text="Select movie" /><br />

</ItemTemplate>

</asp:DataList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:movie_streamConnectionString5 %>"

SelectCommand="SELECT [Movie_ID], [Genre_Category], [Movie_name], [Release_date], [Length], [Synopsis], [Starring], [Director], [Price] FROM [MS_Movies] WHERE ([Movie_name] = @dotnet.itags.org.Movie_name)">

<SelectParameters>

<asp:QueryStringParameter DefaultValue="Movie_name" Name="Movie_name" QueryStringField="Movie_name"

Type="String" />

</SelectParameters>

</asp:SqlDataSource>--

%>

selectfilm.cs code;

using

System;

using

System.Data;

using

System.Data.SqlClient;

using

System.Configuration;

using

System.Collections;

using

System.Web;

using

System.Web.Security;

using

System.Web.UI;

using

System.Web.UI.WebControls;

using

System.Web.UI.WebControls.WebParts;

using

System.Web.UI.HtmlControls;

public

partialclassSelectedFilm : System.Web.UI.Page

{

protectedvoid addToCart(object sender,EventArgs e)

{

if (IsPostBack)

{

Session[

"Movie_IDLabel"] = ("Movie_ID");

Session[

"Movie_nameLabel"] = ("Movie_name");

Session[

"Genre_CategoryLabel"] = ("Genre_Category");

Session[

"Movie_IDLabel"] = ("Movie_ID");

Session[

"Release_dateLabel"] = ("Release_date");

Session[

"LengthLabel"] = ("Length");

Session[

"SynopsisLabel"] = ("Synopsis");

Session[

"StarringLabel"] = ("Starring");

Session[

"DirectorLabel"] = ("Director");

Session[

"PriceLabel"] = ("Price");// Response.Redirect("viewcart.aspx");

}

Response.Redirect(

"viewcart.aspx");

}

And my view cart code;

<%

@dotnet.itags.org.PageLanguage="C#"AutoEventWireup="true"CodeFile="viewcart.aspx.cs"Inherits="viewcart" %>

<!

DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<

htmlxmlns="http://www.w3.org/1999/xhtml">

<

headrunat="server">

<scriptlanguage="javascript"type="text/javascript">

</

script>

</

head>

<

body><formid="Form1"runat="server">

<asp:Labelid="Movie_IDLabel"runat="server"Font-size="30"></asp:Label><br/><br/><asp:Labelid="Movie_nameLabel"runat="server"Font-size="30"></asp:Label><br/><br/><asp:Labelid="PriceLabel"runat="server"Font-size="30"></asp:Label>

</form>

</

body>

</

html>

viewcart cs code

using

System;

using

System.Data;

using

System.Configuration;

using

System.Collections;

using

System.Web;

using

System.Web.Security;

using

System.Web.UI;

using

System.Web.UI.WebControls;

using

System.Web.UI.WebControls.WebParts;

using

System.Web.UI.HtmlControls;

using

System.Web.Configuration;

using

System.Data.SqlClient;

using

System.Text.RegularExpressions;

public

partialclassviewcart : System.Web.UI.Page

{

void Page_Load(object sender,EventArgs e)

{

Movie_IDLabel.Text =

Convert.ToString(Session["Movie_ID"]);

Movie_nameLabel.Text =

Convert.ToString(Session["Movie_name"]);

PriceLabel.Text =

Convert.ToString(Session["Price"]);

}

Hi, I have not gone through all the code you have up there...but here is how you could do it..

On your first page set the session variables and access them on your second page...

I think you want to access the value of the textbox's or label's value in the second page rather than the name of them..

On first page...

Session["variable1"] = textBox1.value;

On the second page

string str = Session["variable1"];

Where as you are doing as the following..

Session["variable1"] = "Text" // where your text is the name of the control from what i see in the example you gave...


Hi thanks for your response, the problem is im trying to bring up a label and not a textbox, how would i go about doing this. thank you

Is there anyone out there who can help me please.


I believe you are saying that you want to get the "text value" of the label...

If thats right, you could do something like

Session["key1"] = label1.text; // this should be done on Page One

One second page, get the value from session as Session["key1"]

Session variable is not transferred to an asp page?

I have a asp.net project with all major pages written in aspx, but I want to keep an existing asp page in the same directory as the aspx files. But when the asp page gets loaded, the session variable is not recognized. Is this the case and why?To be specific, when I load the asp.net app using the address of http://localhost/myproj/ it works fine, and the asp page could read the session variable assigned by an aspx page. But if I use my computer name, say http://keystrokes_win2k/myproj/ then it doesn't work.

Any ideas?
No, the ASP and ASP.NET sessions are two separate objects that do not share their data. There are some third party session objects that you can use to communicate between the two environments, though.
What is the third party session object, please provide some lead ?

Session variable is lost between ASP & ASP.NET pages

Hi folks,
I must be missing something here. I have an ASP page that I create a
Session variable in as follows.
Session ("name")="Joe"
In an ASP.NET page in the same project and the same session, I call the
Session variable as follows:
Dim str As String
str = Session("name")
When I do a Response.Write (str), nothing writes to the screen.
Any thoughts on what is happening here would be appreciatedUhhhh...
Yeah , that is what it will do. It doesn't work like that.
You can check this out
http://www.asp101.com/articles/sidn...ate/default.asp
but ... the thing surprising you, isn't surprising at all. They are
different technologies...
with nothing but the phrase "asp" in common.
"glenn" <glenn@.discussions.microsoft.com> wrote in message
news:16EE097D-5F1E-4742-AB89-E05057E59EA0@.microsoft.com...
> Hi folks,
> I must be missing something here. I have an ASP page that I create a
> Session variable in as follows.
> Session ("name")="Joe"
> In an ASP.NET page in the same project and the same session, I call the
> Session variable as follows:
> Dim str As String
> str = Session("name")
> When I do a Response.Write (str), nothing writes to the screen.
> Any thoughts on what is happening here would be appreciated
re:
>nothing but the phrase "asp" in common
Absolutely...
The seminal work on sharing session state between ASP and ASP.NET is :
"How to Share Session State Between Classic ASP and ASP.NET"
http://msdn.microsoft.com/library/d...
rttoaspnet.asp
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"sloan" <sloan@.ipass.net> wrote in message news:%23zLsJArUGHA.1160@.TK2MSFTNGP09.phx.gbl...[
color=darkred]
> Uhhhh...
> Yeah , that is what it will do. It doesn't work like that.
> You can check this out
> http://www.asp101.com/articles/sidn...ate/default.asp
> but ... the thing surprising you, isn't surprising at all. They are
> different technologies...with nothing but the phrase "asp" in common.
>
>
> "glenn" <glenn@.discussions.microsoft.com> wrote in message
> news:16EE097D-5F1E-4742-AB89-E05057E59EA0@.microsoft.com...
>[/color]

Session variable is lost between ASP & ASP.NET pages

Hi folks,

I must be missing something here. I have an ASP page that I create a
Session variable in as follows.

Session ("name")="Joe"

In an ASP.NET page in the same project and the same session, I call the
Session variable as follows:

Dim str As String
str = Session("name")

When I do a Response.Write (str), nothing writes to the screen.

Any thoughts on what is happening here would be appreciatedUhhhh...

Yeah , that is what it will do. It doesn't work like that.

You can check this out
http://www.asp101.com/articles/sidn...ate/default.asp

but ... the thing surprising you, isn't surprising at all. They are
different technologies...
with nothing but the phrase "asp" in common.

"glenn" <glenn@.discussions.microsoft.com> wrote in message
news:16EE097D-5F1E-4742-AB89-E05057E59EA0@.microsoft.com...
> Hi folks,
> I must be missing something here. I have an ASP page that I create a
> Session variable in as follows.
> Session ("name")="Joe"
> In an ASP.NET page in the same project and the same session, I call the
> Session variable as follows:
> Dim str As String
> str = Session("name")
> When I do a Response.Write (str), nothing writes to the screen.
> Any thoughts on what is happening here would be appreciated
re:
>nothing but the phrase "asp" in common

Absolutely...

The seminal work on sharing session state between ASP and ASP.NET is :

"How to Share Session State Between Classic ASP and ASP.NET"
http://msdn.microsoft.com/library/d...erttoaspnet.asp

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"sloan" <sloan@.ipass.net> wrote in message news:%23zLsJArUGHA.1160@.TK2MSFTNGP09.phx.gbl...
> Uhhhh...
> Yeah , that is what it will do. It doesn't work like that.
> You can check this out
> http://www.asp101.com/articles/sidn...ate/default.asp
> but ... the thing surprising you, isn't surprising at all. They are
> different technologies...with nothing but the phrase "asp" in common.
>
>
> "glenn" <glenn@.discussions.microsoft.com> wrote in message
> news:16EE097D-5F1E-4742-AB89-E05057E59EA0@.microsoft.com...
>> Hi folks,
>>
>> I must be missing something here. I have an ASP page that I create a
>> Session variable in as follows.
>>
>> Session ("name")="Joe"
>>
>> In an ASP.NET page in the same project and the same session, I call the
>> Session variable as follows:
>>
>> Dim str As String
>> str = Session("name")
>>
>> When I do a Response.Write (str), nothing writes to the screen.
>>
>> Any thoughts on what is happening here would be appreciated

Session variable lost between pages

Here is a very interesting scenario.

I have a simple test application that loads a page and sets a session
variable on the load event. On the first page there is a link to a second
page. The load event of the second page displays the value of the session
variable.

The problem is that when I use a W2k machine, this little test works
perfect. Session variable value is displayed on the second page. However,
when I use my XPPro machine, the session variable is lost and nothing is
displayed.

Same version of IE. Same ASP.NET server. Just a different browser. I have
already played around with the privacy settings with no success. I am not
suspect of the server at this point, because the w2k computer works fine.

Any thoughts would be appreciated.

Thanks,
Marc.Are you sure that the session state setting is enabled within IIS? Although
ASP.Net may be setup the same, and the application settings may be the same,
the IIS settings themselves are a little different between IIS 5.0 and 5.1.
Session state usually starts with the web server itself and then it goes
down to ASP/ASP.Net so I would suspect IIS first, then the ASP/ASP.Net
settings second.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"Marc Rivait" <marcr@.rivaitsoftware.com> wrote in message
news:%23zZfnswoDHA.2528@.TK2MSFTNGP10.phx.gbl...
> Here is a very interesting scenario.
> I have a simple test application that loads a page and sets a session
> variable on the load event. On the first page there is a link to a second
> page. The load event of the second page displays the value of the session
> variable.
> The problem is that when I use a W2k machine, this little test works
> perfect. Session variable value is displayed on the second page.
However,
> when I use my XPPro machine, the session variable is lost and nothing is
> displayed.
> Same version of IE. Same ASP.NET server. Just a different browser. I
have
> already played around with the privacy settings with no success. I am not
> suspect of the server at this point, because the w2k computer works fine.
> Any thoughts would be appreciated.
> Thanks,
> Marc.
Thanks Mark.

There is only one server that I am hitting from two different browsers,
therefore I believe the problems lies within the browser since the server is
the same.

Session state is enabled on the server.

Marc.

"Mark Fitzpatrick" <markfitz@.fitzme.com> wrote in message
news:OmPw$vxoDHA.2588@.tk2msftngp13.phx.gbl...
> Are you sure that the session state setting is enabled within IIS?
Although
> ASP.Net may be setup the same, and the application settings may be the
same,
> the IIS settings themselves are a little different between IIS 5.0 and
5.1.
> Session state usually starts with the web server itself and then it goes
> down to ASP/ASP.Net so I would suspect IIS first, then the ASP/ASP.Net
> settings second.
> Hope this helps,
> Mark Fitzpatrick
> Microsoft MVP - FrontPage
> "Marc Rivait" <marcr@.rivaitsoftware.com> wrote in message
> news:%23zZfnswoDHA.2528@.TK2MSFTNGP10.phx.gbl...
> > Here is a very interesting scenario.
> > I have a simple test application that loads a page and sets a session
> > variable on the load event. On the first page there is a link to a
second
> > page. The load event of the second page displays the value of the
session
> > variable.
> > The problem is that when I use a W2k machine, this little test works
> > perfect. Session variable value is displayed on the second page.
> However,
> > when I use my XPPro machine, the session variable is lost and nothing is
> > displayed.
> > Same version of IE. Same ASP.NET server. Just a different browser. I
> have
> > already played around with the privacy settings with no success. I am
not
> > suspect of the server at this point, because the w2k computer works
fine.
> > Any thoughts would be appreciated.
> > Thanks,
> > Marc.
I am away from my computer with VS .Net, so I can't check, but as I recall
there are different methods for persisting the session variables. I think
one of them uses cookies. Is it possible that is the method being used for
your site and that the computer losing the session variables does not accept
cookies.

"Marc Rivait" <marcr@.rivaitsoftware.com> wrote in message
news:OxrfxcyoDHA.2512@.TK2MSFTNGP09.phx.gbl...
> Thanks Mark.
> There is only one server that I am hitting from two different browsers,
> therefore I believe the problems lies within the browser since the server
is
> the same.
> Session state is enabled on the server.
> Marc.
>
> "Mark Fitzpatrick" <markfitz@.fitzme.com> wrote in message
> news:OmPw$vxoDHA.2588@.tk2msftngp13.phx.gbl...
> > Are you sure that the session state setting is enabled within IIS?
> Although
> > ASP.Net may be setup the same, and the application settings may be the
> same,
> > the IIS settings themselves are a little different between IIS 5.0 and
> 5.1.
> > Session state usually starts with the web server itself and then it goes
> > down to ASP/ASP.Net so I would suspect IIS first, then the ASP/ASP.Net
> > settings second.
> > Hope this helps,
> > Mark Fitzpatrick
> > Microsoft MVP - FrontPage
> > "Marc Rivait" <marcr@.rivaitsoftware.com> wrote in message
> > news:%23zZfnswoDHA.2528@.TK2MSFTNGP10.phx.gbl...
> > > Here is a very interesting scenario.
> > > > I have a simple test application that loads a page and sets a session
> > > variable on the load event. On the first page there is a link to a
> second
> > > page. The load event of the second page displays the value of the
> session
> > > variable.
> > > > The problem is that when I use a W2k machine, this little test works
> > > perfect. Session variable value is displayed on the second page.
> > However,
> > > when I use my XPPro machine, the session variable is lost and nothing
is
> > > displayed.
> > > > Same version of IE. Same ASP.NET server. Just a different browser.
I
> > have
> > > already played around with the privacy settings with no success. I am
> not
> > > suspect of the server at this point, because the w2k computer works
> fine.
> > > > Any thoughts would be appreciated.
> > > > Thanks,
> > > Marc.
> >
Have completed disabled the privacy settings on the computer losing the
session variable. My thinking was the same that it must be related to
cookies, but this has not helped.

Marc.

"William F. LaMartin" <lamartin@.ix.netcom.com> wrote in message
news:%23OUS6h1oDHA.372@.TK2MSFTNGP11.phx.gbl...
> I am away from my computer with VS .Net, so I can't check, but as I recall
> there are different methods for persisting the session variables. I think
> one of them uses cookies. Is it possible that is the method being used
for
> your site and that the computer losing the session variables does not
accept
> cookies.
>
> "Marc Rivait" <marcr@.rivaitsoftware.com> wrote in message
> news:OxrfxcyoDHA.2512@.TK2MSFTNGP09.phx.gbl...
> > Thanks Mark.
> > There is only one server that I am hitting from two different browsers,
> > therefore I believe the problems lies within the browser since the
server
> is
> > the same.
> > Session state is enabled on the server.
> > Marc.
> > "Mark Fitzpatrick" <markfitz@.fitzme.com> wrote in message
> > news:OmPw$vxoDHA.2588@.tk2msftngp13.phx.gbl...
> > > Are you sure that the session state setting is enabled within IIS?
> > Although
> > > ASP.Net may be setup the same, and the application settings may be the
> > same,
> > > the IIS settings themselves are a little different between IIS 5.0 and
> > 5.1.
> > > Session state usually starts with the web server itself and then it
goes
> > > down to ASP/ASP.Net so I would suspect IIS first, then the ASP/ASP.Net
> > > settings second.
> > > > Hope this helps,
> > > Mark Fitzpatrick
> > > Microsoft MVP - FrontPage
> > > > "Marc Rivait" <marcr@.rivaitsoftware.com> wrote in message
> > > news:%23zZfnswoDHA.2528@.TK2MSFTNGP10.phx.gbl...
> > > > Here is a very interesting scenario.
> > > > > > I have a simple test application that loads a page and sets a
session
> > > > variable on the load event. On the first page there is a link to a
> > second
> > > > page. The load event of the second page displays the value of the
> > session
> > > > variable.
> > > > > > The problem is that when I use a W2k machine, this little test works
> > > > perfect. Session variable value is displayed on the second page.
> > > However,
> > > > when I use my XPPro machine, the session variable is lost and
nothing
> is
> > > > displayed.
> > > > > > Same version of IE. Same ASP.NET server. Just a different browser.
> I
> > > have
> > > > already played around with the privacy settings with no success. I
am
> > not
> > > > suspect of the server at this point, because the w2k computer works
> > fine.
> > > > > > Any thoughts would be appreciated.
> > > > > > Thanks,
> > > > Marc.
> > > > > >
I have found the answer and am posting it here to help anyone else avoid my
pain! So simple is the answer. ZoneAlarm Pro.

It seems that using any of the privacy settings in ZoneAlarmPro cause some
very unusual problems with asp.net. Zonealarm was consuming the cookies
causing the session to be reset on each postback. I have disabled the
privacy settings and everything is back to normal. In doing some research
on the web, I have read the Norton and Blackice do not create this problem.
This is something I will be doing more research into to confirm it for
myself.

My advice to all is when experiencing any problem with asp.net the first
thing you should do is disable virus and firewall software. Hopefully this
is advice I will remember next time myself. It is very easy to have a
problem consume you to the point where you forget the simple basic things.

Marc.

"Marc Rivait" <marcr@.rivaitsoftware.com> wrote in message
news:OqX7C44oDHA.1496@.TK2MSFTNGP11.phx.gbl...
> Have completed disabled the privacy settings on the computer losing the
> session variable. My thinking was the same that it must be related to
> cookies, but this has not helped.
> Marc.
>
> "William F. LaMartin" <lamartin@.ix.netcom.com> wrote in message
> news:%23OUS6h1oDHA.372@.TK2MSFTNGP11.phx.gbl...
> > I am away from my computer with VS .Net, so I can't check, but as I
recall
> > there are different methods for persisting the session variables. I
think
> > one of them uses cookies. Is it possible that is the method being used
> for
> > your site and that the computer losing the session variables does not
> accept
> > cookies.
> > "Marc Rivait" <marcr@.rivaitsoftware.com> wrote in message
> > news:OxrfxcyoDHA.2512@.TK2MSFTNGP09.phx.gbl...
> > > Thanks Mark.
> > > > There is only one server that I am hitting from two different
browsers,
> > > therefore I believe the problems lies within the browser since the
> server
> > is
> > > the same.
> > > > Session state is enabled on the server.
> > > > Marc.
> > > > > > "Mark Fitzpatrick" <markfitz@.fitzme.com> wrote in message
> > > news:OmPw$vxoDHA.2588@.tk2msftngp13.phx.gbl...
> > > > Are you sure that the session state setting is enabled within IIS?
> > > Although
> > > > ASP.Net may be setup the same, and the application settings may be
the
> > > same,
> > > > the IIS settings themselves are a little different between IIS 5.0
and
> > > 5.1.
> > > > Session state usually starts with the web server itself and then it
> goes
> > > > down to ASP/ASP.Net so I would suspect IIS first, then the
ASP/ASP.Net
> > > > settings second.
> > > > > > Hope this helps,
> > > > Mark Fitzpatrick
> > > > Microsoft MVP - FrontPage
> > > > > > "Marc Rivait" <marcr@.rivaitsoftware.com> wrote in message
> > > > news:%23zZfnswoDHA.2528@.TK2MSFTNGP10.phx.gbl...
> > > > > Here is a very interesting scenario.
> > > > > > > > I have a simple test application that loads a page and sets a
> session
> > > > > variable on the load event. On the first page there is a link to
a
> > > second
> > > > > page. The load event of the second page displays the value of the
> > > session
> > > > > variable.
> > > > > > > > The problem is that when I use a W2k machine, this little test
works
> > > > > perfect. Session variable value is displayed on the second page.
> > > > However,
> > > > > when I use my XPPro machine, the session variable is lost and
> nothing
> > is
> > > > > displayed.
> > > > > > > > Same version of IE. Same ASP.NET server. Just a different
browser.
> > I
> > > > have
> > > > > already played around with the privacy settings with no success.
I
> am
> > > not
> > > > > suspect of the server at this point, because the w2k computer
works
> > > fine.
> > > > > > > > Any thoughts would be appreciated.
> > > > > > > > Thanks,
> > > > > Marc.
> > > > > > > > > > > >

session variable lost across different folders

Hi

A session variable that I have created can only be shared by the pages within the same directory where the page containing the session variable is sitting. Once I redirect the page to another page outside the folder (a different folder), the session variable is lost (empty). I understood that a session variable is meant to be used across all files in an application. Am I missing something here? Or I didn't setup properly?

Please help.

ThanksIs is useable throughout and application. IE if you have an application directory called /myapp then all folders under that directory will accept the session variable. (I think). There are a number of ways to get around this. If you tell me were the 2 differnt folders are located,(relative to eachother). and what kind of value you are trying to pass I'll be able to help you.

One last thing: what kinda of script are you trying to write? login page, shopping cart, etc...

Ryder
Thanks Ryder!

I have an application folder called 'QSAConnect' and under this folder there are several sub-folders. The page with the session variable called Session("StudentID") is saved in a sub-folder called 'AbsRecordEntry', and I want to redirect this page to another page, called absreport.aspx, which requires this Session("StudentID") as a passing parameter for all the functions. The target page(absreport.aspx) is located in a sub-directory called 'AbsReport'. Here is the code:


Sub btnViewReport_Click(sender As Object, e As EventArgs)
Dim strStudentID as string
strStudentID=lbxStudentLastName.Items(lbxStudentLastName.SelectedIndex).Value
Session("StudentID") = strStudentID
response.redirect(".../AbsReport/absreport.aspx")

End Sub


This produced an empty session variable when the absreport.aspx loaded. But if I place the file absreport.aspx under AbsRecordEntry folder and change code to:

response.redirect("absreport.aspx")

there is no problem.

I hope you can understand my explanation.

Thanks again

Haiyi
hmmm, I created a similar situation on my testing server a few minutes ago and it worked fine. But what I did notice is that i wrote my response.redirect line a bit differntly and I think that may be it.

see, here is how you wrote yours: response.redirect(".../AbsReport/absreport.aspx")
and this is how I wrote mine: response.redirect("../AbsReport/absreport.aspx")

notice I only have 2 periods not 3. So my next step was to try my code with 3 periods. It generated an error, so i beleive that may be it. The only onther thing I could think of off the top of my head was that maybe the folder AbsRecordEntry or AbsReport is also an application directory. because this would cause a problem perhaps.

Let me know if this works.

Ryder

session variable not working properly

Hi

i've some web user controls in one folder and web pages in some other
folder.

and i've included header web user control in all my web pages.
and in that user control wrote code to get the logged in user details to be
displayed in header.

In login user control, the logged in userid was stored in a session.

in one of web pages i'm retrieving the values based on the value stored in
session i set in login control.

and when i put cooment to the code in header control then the value is
maintained in session, if i remove comments then it is not storing any data
in session.

whats the problem with my code?

Thanks And Regards
Yoshitha.Dear Gurunadh,

Just Make sure you are not overriding the session variable in the
Header control.
A user controls page load event is raised after page's pageload event
is raised. so if you store or clear session in user control it will
override the value of the page's code.

But it will be helpful if you provide sample code in header control.

Thanks

Md. Masudur Rahman
www.kaz.com.bd
KAZ Software Ltd.
Software outsourcing made simple...

Gurunadh wrote:

Quote:

Originally Posted by

Hi
>
i've some web user controls in one folder and web pages in some other
folder.
>
and i've included header web user control in all my web pages.
and in that user control wrote code to get the logged in user details to be
displayed in header.
>
In login user control, the logged in userid was stored in a session.
>
in one of web pages i'm retrieving the values based on the value stored in
session i set in login control.
>
and when i put cooment to the code in header control then the value is
maintained in session, if i remove comments then it is not storing any data
in session.
>
whats the problem with my code?
>
Thanks And Regards
Yoshitha.


Hi Rahman

private void Page_Load(object sender, System.EventArgs e)

{

// Put user code to initialize the page here

if(! IsPostBack)

{

ePortalDataBase db=new ePortalDataBase();

OleDbConnection con;

con=db.openconnection();

con.Open ();

if(db.RunQuery("Select aliasname,sitetitle from EL_PortalRegistration where
siteaddress='siteadress' "))

{

while(db.result.Read())

{

lblUser.Text=db.result.GetValue(0).ToString() ;

lblTitle.Text=db.result.GetValue(1).ToString() ;

}

}

con.Close();

}

private void btnSignOut_Click(object sender, System.EventArgs e)

{

Session.Abandon();

Server.Transfer("default.aspx");

}

this is the code i've written in header control

and this code i've writen in login control

private void btnLogin_Click(object sender, System.EventArgs e)

{

Session["EmailId"]=txtEmailId.Text;

Response.Redirect("Eportal_Courses.aspx") ;

}

thanks and REgards

Yoshitha

"Masudur" <munnacs@.gmail.comwrote in message
news:1164613193.483588.194400@.h54g2000cwb.googlegr oups.com...

Quote:

Originally Posted by

Dear Gurunadh,
>
Just Make sure you are not overriding the session variable in the
Header control.
A user controls page load event is raised after page's pageload event
is raised. so if you store or clear session in user control it will
override the value of the page's code.
>
But it will be helpful if you provide sample code in header control.
>
Thanks
>
Md. Masudur Rahman
www.kaz.com.bd
KAZ Software Ltd.
Software outsourcing made simple...
>
Gurunadh wrote:

Quote:

Originally Posted by

>Hi
>>
>i've some web user controls in one folder and web pages in some other
>folder.
>>
>and i've included header web user control in all my web pages.
>and in that user control wrote code to get the logged in user details to
>be
>displayed in header.
>>
>In login user control, the logged in userid was stored in a session.
>>
>in one of web pages i'm retrieving the values based on the value stored
>in
>session i set in login control.
>>
>and when i put cooment to the code in header control then the value is
>maintained in session, if i remove comments then it is not storing any
>data
>in session.
>>
>whats the problem with my code?
>>
>Thanks And Regards
>Yoshitha.


>

session variable not working properly

Hi
i've some web user controls in one folder and web pages in some other
folder.
and i've included header web user control in all my web pages.
and in that user control wrote code to get the logged in user details to be
displayed in header.
In login user control, the logged in userid was stored in a session.
in one of web pages i'm retrieving the values based on the value stored in
session i set in login control.
and when i put cooment to the code in header control then the value is
maintained in session, if i remove comments then it is not storing any data
in session.
whats the problem with my code?
Thanks And Regards
Yoshitha.Dear Gurunadh,
Just Make sure you are not overriding the session variable in the
Header control.
A user controls page load event is raised after page's pageload event
is raised. so if you store or clear session in user control it will
override the value of the page's code.
But it will be helpful if you provide sample code in header control.
Thanks
Md. Masudur Rahman
www.kaz.com.bd
KAZ Software Ltd.
Software outsourcing made simple...
Gurunadh wrote:
> Hi
> i've some web user controls in one folder and web pages in some other
> folder.
> and i've included header web user control in all my web pages.
> and in that user control wrote code to get the logged in user details to b
e
> displayed in header.
> In login user control, the logged in userid was stored in a session.
> in one of web pages i'm retrieving the values based on the value stored in
> session i set in login control.
> and when i put cooment to the code in header control then the value is
> maintained in session, if i remove comments then it is not storing any dat
a
> in session.
> whats the problem with my code?
> Thanks And Regards
> Yoshitha.
Hi Rahman
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(! IsPostBack)
{
ePortalDataBase db=new ePortalDataBase();
OleDbConnection con;
con=db.openconnection();
con.Open ();
if(db.RunQuery("Select aliasname,sitetitle from EL_PortalRegistration where
siteaddress='siteadress' "))
{
while(db.result.Read())
{
lblUser.Text=db.result.GetValue(0).ToString() ;
lblTitle.Text=db.result.GetValue(1).ToString() ;
}
}
con.Close();
}
private void btnSignOut_Click(object sender, System.EventArgs e)
{
Session.Abandon();
Server.Transfer("default.aspx");
}
this is the code i've written in header control
and this code i've writen in login control
private void btnLogin_Click(object sender, System.EventArgs e)
{
Session["EmailId"]=txtEmailId.Text;
Response.Redirect("Eportal_Courses.aspx") ;
}
thanks and REgards
Yoshitha
"Masudur" <munnacs@.gmail.com> wrote in message
news:1164613193.483588.194400@.h54g2000cwb.googlegroups.com...
> Dear Gurunadh,
> Just Make sure you are not overriding the session variable in the
> Header control.
> A user controls page load event is raised after page's pageload event
> is raised. so if you store or clear session in user control it will
> override the value of the page's code.
> But it will be helpful if you provide sample code in header control.
> Thanks
> Md. Masudur Rahman
> www.kaz.com.bd
> KAZ Software Ltd.
> Software outsourcing made simple...
> Gurunadh wrote:
>

Saturday, March 24, 2012

Session variable scope in a Load Balanced environment

I have the following scenario in a true load balanced environment (without
sticky sessions):
There are 2 ASPX pages. I want to pass an object from the first page to the
second page. On the btnContinue_Click event of Page1.aspx, I create the
object and store it in a session variable. The next statement would be
Response.Redirect("Page2.aspx"). The code appears like this:
private void btnContinue_Click(object sender, EventArgs e)
{
OrderInfo orderInfo = new OrderInfo();
orderInfo.Property1 = "Property1";
orderInfo.Property2 = "Property2" Session["orderInfo"] =
orderInfo;
Response.Redirect("Page2.aspx");
}On Page2.aspx, on the Page_Load event, I retrieve the object from the
Session variable and put it in a OrderInfo object and then remove the
session variable. The code looks similar to below:
void Page_Load(object sender, EventArgs e)
{
OrderInfo orderInfo = new OrderInfo();
orderInfo = (OrderInfo)Session["orderInfo"];
Session.Remove("orderInfo");
}My understanding is - creating the object, putting it in a Session
variable, redirecting to another page and retrieval of the object in the
second page - all these happens in one server call. I don't care if the
Session variable is lost after this call. That is the reason I remove the
variable from session state.
My question is - are there any chances that the Session variable will lose
its value in the above scenario because of load balancing?
Any help will be appriciated.
Thanks!On Wed, 28 Dec 2005 11:57:17 +0530, Vidyadhar Joshi wrote:

> I have the following scenario in a true load balanced environment (without
> sticky sessions):
> There are 2 ASPX pages. I want to pass an object from the first page to th
e
> second page. On the btnContinue_Click event of Page1.aspx, I create the
> object and store it in a session variable. The next statement would be
> Response.Redirect("Page2.aspx"). The code appears like this:
> private void btnContinue_Click(object sender, EventArgs e)
> {
> OrderInfo orderInfo = new OrderInfo();
> orderInfo.Property1 = "Property1";
> orderInfo.Property2 = "Property2" Session["orderInfo"] =
> orderInfo;
> Response.Redirect("Page2.aspx");
> }On Page2.aspx, on the Page_Load event, I retrieve the object from the
> Session variable and put it in a OrderInfo object and then remove the
> session variable. The code looks similar to below:
> void Page_Load(object sender, EventArgs e)
> {
> OrderInfo orderInfo = new OrderInfo();
> orderInfo = (OrderInfo)Session["orderInfo"];
> Session.Remove("orderInfo");
> }My understanding is - creating the object, putting it in a Session
> variable, redirecting to another page and retrieval of the object in the
> second page - all these happens in one server call. I don't care if the
> Session variable is lost after this call. That is the reason I remove the
> variable from session state.
> My question is - are there any chances that the Session variable will lose
> its value in the above scenario because of load balancing?
> Any help will be appriciated.
> Thanks!
In my experience, load balancing (without sticky), will create problems
for you.
You will also have problems with the Session being dumped due to timeout,
restarts of the server, etc.

Session variable scope in a Load Balanced environment

I have the following scenario in a true load balanced environment (without
sticky sessions):

There are 2 ASPX pages. I want to pass an object from the first page to the
second page. On the btnContinue_Click event of Page1.aspx, I create the
object and store it in a session variable. The next statement would be
Response.Redirect("Page2.aspx"). The code appears like this:
private void btnContinue_Click(object sender, EventArgs e)
{
OrderInfo orderInfo = new OrderInfo();
orderInfo.Property1 = "Property1";
orderInfo.Property2 = "Property2" Session["orderInfo"] =
orderInfo;
Response.Redirect("Page2.aspx");
}On Page2.aspx, on the Page_Load event, I retrieve the object from the
Session variable and put it in a OrderInfo object and then remove the
session variable. The code looks similar to below:
void Page_Load(object sender, EventArgs e)
{
OrderInfo orderInfo = new OrderInfo();
orderInfo = (OrderInfo)Session["orderInfo"];
Session.Remove("orderInfo");
}My understanding is - creating the object, putting it in a Session
variable, redirecting to another page and retrieval of the object in the
second page - all these happens in one server call. I don't care if the
Session variable is lost after this call. That is the reason I remove the
variable from session state.

My question is - are there any chances that the Session variable will lose
its value in the above scenario because of load balancing?

Any help will be appriciated.

Thanks!On Wed, 28 Dec 2005 11:57:17 +0530, Vidyadhar Joshi wrote:

> I have the following scenario in a true load balanced environment (without
> sticky sessions):
> There are 2 ASPX pages. I want to pass an object from the first page to the
> second page. On the btnContinue_Click event of Page1.aspx, I create the
> object and store it in a session variable. The next statement would be
> Response.Redirect("Page2.aspx"). The code appears like this:
> private void btnContinue_Click(object sender, EventArgs e)
> {
> OrderInfo orderInfo = new OrderInfo();
> orderInfo.Property1 = "Property1";
> orderInfo.Property2 = "Property2" Session["orderInfo"] =
> orderInfo;
> Response.Redirect("Page2.aspx");
> }On Page2.aspx, on the Page_Load event, I retrieve the object from the
> Session variable and put it in a OrderInfo object and then remove the
> session variable. The code looks similar to below:
> void Page_Load(object sender, EventArgs e)
> {
> OrderInfo orderInfo = new OrderInfo();
> orderInfo = (OrderInfo)Session["orderInfo"];
> Session.Remove("orderInfo");
> }My understanding is - creating the object, putting it in a Session
> variable, redirecting to another page and retrieval of the object in the
> second page - all these happens in one server call. I don't care if the
> Session variable is lost after this call. That is the reason I remove the
> variable from session state.
> My question is - are there any chances that the Session variable will lose
> its value in the above scenario because of load balancing?
> Any help will be appriciated.
> Thanks!
In my experience, load balancing (without sticky), will create problems
for you.
You will also have problems with the Session being dumped due to timeout,
restarts of the server, etc.

Session variable VS HREF parameters...

I already use session variable in my project to set a session timeout when
the user doesn't do anything for 10 minutes.

When I call other pages, I often use parameters in HREF link.

I was wondering if it was better to pass parameter from page to page as
session variable instead of doing it in HREF link?

Thx for the hint !The first part of your message is very confusing to me, as Sessions time out
all by themselves. However, I can help you with your other question.

> When I call other pages, I often use parameters in HREF link.
> I was wondering if it was better to pass parameter from page to page as
> session variable instead of doing it in HREF link?

You have a couple of issues here. When you pass data via URL, you are
exposing it to the user, which can be a security risk, so one consideration
is how sensitive the data is. If it's not sensitive, you're fine, as long as
you make sure that the user can't create a parameterized URL that would
cause some problem. One of the advantages of using QueryString parameters is
that the user can bookmark a dynamic page, as the bookmark will have the
parameters in it.

As for Sessions, they can be problematic as well, since they time out after
a certain interval of inactivity. As long as you make sure to handle this
eventuality, Session is fine.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"+The_Taco+" <dominic.feron@.dessausoprin.com> wrote in message
news:eZ2jciO7DHA.488@.TK2MSFTNGP12.phx.gbl...
> I already use session variable in my project to set a session timeout when
> the user doesn't do anything for 10 minutes.
> When I call other pages, I often use parameters in HREF link.
> I was wondering if it was better to pass parameter from page to page as
> session variable instead of doing it in HREF link?
> Thx for the hint !
I think he means that he is using session as a crewd way to timeout a user
by setting session.timeout = 10 and checking for it on each postback.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"Kevin Spencer" <kevin@.takempis.com> wrote in message
news:%23%23MS0$O7DHA.1852@.TK2MSFTNGP10.phx.gbl...
> The first part of your message is very confusing to me, as Sessions time
out
> all by themselves. However, I can help you with your other question.
> > When I call other pages, I often use parameters in HREF link.
> > I was wondering if it was better to pass parameter from page to page as
> > session variable instead of doing it in HREF link?
> You have a couple of issues here. When you pass data via URL, you are
> exposing it to the user, which can be a security risk, so one
consideration
> is how sensitive the data is. If it's not sensitive, you're fine, as long
as
> you make sure that the user can't create a parameterized URL that would
> cause some problem. One of the advantages of using QueryString parameters
is
> that the user can bookmark a dynamic page, as the bookmark will have the
> parameters in it.
> As for Sessions, they can be problematic as well, since they time out
after
> a certain interval of inactivity. As long as you make sure to handle this
> eventuality, Session is fine.
> --
> HTH,
> Kevin Spencer
> .Net Developer
> Microsoft MVP
> Big things are made up
> of lots of little things.
>
> "+The_Taco+" <dominic.feron@.dessausoprin.com> wrote in message
> news:eZ2jciO7DHA.488@.TK2MSFTNGP12.phx.gbl...
> > I already use session variable in my project to set a session timeout
when
> > the user doesn't do anything for 10 minutes.
> > When I call other pages, I often use parameters in HREF link.
> > I was wondering if it was better to pass parameter from page to page as
> > session variable instead of doing it in HREF link?
> > Thx for the hint !

Session Variable vs Cookie

Are Session variables the same as a cookie? In reading a couple of pages I
got from searches, I don't get the difference. Basically, I am currently
using simple session variables (e.g. Session("UserName") =
txtLastName.Text). I think they are expiring for some users (longer
sessions?) and I need to be able to set the expiration to something like
Now() plus 2 hours.
What is the right way to do this?
WayneNope: Session and cookies are not the same thing. A cookie is a text file
that lives on the user's computer. Session is typically the Web server's
memory and exists for 20 minutes by default. Session can be a lot more than
that, though. You can accomplish what you need to in a variety of ways, but
it might be easiest for you to go with cookies. Read up in the online help
on cookies - how to create them, set expiration time, etc...
K
"Wayne Wengert" <wayneDONTWANTSPAM@.wengert.com> wrote in message
news:ee$KRCsPEHA.1312@.TK2MSFTNGP12.phx.gbl...
> Are Session variables the same as a cookie? In reading a couple of pages I
> got from searches, I don't get the difference. Basically, I am currently
> using simple session variables (e.g. Session("UserName") =
> txtLastName.Text). I think they are expiring for some users (longer
> sessions?) and I need to be able to set the expiration to something like
> Now() plus 2 hours.
> What is the right way to do this?
> Wayne
>
Sessions are not really cookies. Basically, session variables are kept in
memory on the server (or through another method such as a database). They
set a cookie on the browser with information to identify exactly what
session the browser is part of. Sessions are usually kept short so that the
server can then close them out and release their resources frequently. That
way, you don't end up with hundrends of sessions active that actually don't
have any users doing anything (sessions don't close when someone browses to
another web site). For things like login information, shorter sessions are
good because if a user leaves their computer and someone else walks up, the
window of opportunity for such an error is reduced. You may want to see what
is useful to put into cookies if you need to keep good control over the time
a value is stored for without eating up tons of server resources. You may
also want to look at ASP.Net's forms authentication features as it also has
a sliding expiration for user information. In other word, the timeout is
refreshed whenever the user grabs another page on the site.
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
"Wayne Wengert" <wayneDONTWANTSPAM@.wengert.com> wrote in message
news:ee$KRCsPEHA.1312@.TK2MSFTNGP12.phx.gbl...
> Are Session variables the same as a cookie? In reading a couple of pages I
> got from searches, I don't get the difference. Basically, I am currently
> using simple session variables (e.g. Session("UserName") =
> txtLastName.Text). I think they are expiring for some users (longer
> sessions?) and I need to be able to set the expiration to something like
> Now() plus 2 hours.
> What is the right way to do this?
> Wayne
>

Session Variable vs Cookie

Are Session variables the same as a cookie? In reading a couple of pages I
got from searches, I don't get the difference. Basically, I am currently
using simple session variables (e.g. Session("UserName") =
txtLastName.Text). I think they are expiring for some users (longer
sessions?) and I need to be able to set the expiration to something like
Now() plus 2 hours.

What is the right way to do this?

WayneNope: Session and cookies are not the same thing. A cookie is a text file
that lives on the user's computer. Session is typically the Web server's
memory and exists for 20 minutes by default. Session can be a lot more than
that, though. You can accomplish what you need to in a variety of ways, but
it might be easiest for you to go with cookies. Read up in the online help
on cookies - how to create them, set expiration time, etc...

K

"Wayne Wengert" <wayneDONTWANTSPAM@.wengert.com> wrote in message
news:ee$KRCsPEHA.1312@.TK2MSFTNGP12.phx.gbl...
> Are Session variables the same as a cookie? In reading a couple of pages I
> got from searches, I don't get the difference. Basically, I am currently
> using simple session variables (e.g. Session("UserName") =
> txtLastName.Text). I think they are expiring for some users (longer
> sessions?) and I need to be able to set the expiration to something like
> Now() plus 2 hours.
> What is the right way to do this?
> Wayne
Sessions are not really cookies. Basically, session variables are kept in
memory on the server (or through another method such as a database). They
set a cookie on the browser with information to identify exactly what
session the browser is part of. Sessions are usually kept short so that the
server can then close them out and release their resources frequently. That
way, you don't end up with hundrends of sessions active that actually don't
have any users doing anything (sessions don't close when someone browses to
another web site). For things like login information, shorter sessions are
good because if a user leaves their computer and someone else walks up, the
window of opportunity for such an error is reduced. You may want to see what
is useful to put into cookies if you need to keep good control over the time
a value is stored for without eating up tons of server resources. You may
also want to look at ASP.Net's forms authentication features as it also has
a sliding expiration for user information. In other word, the timeout is
refreshed whenever the user grabs another page on the site.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"Wayne Wengert" <wayneDONTWANTSPAM@.wengert.com> wrote in message
news:ee$KRCsPEHA.1312@.TK2MSFTNGP12.phx.gbl...
> Are Session variables the same as a cookie? In reading a couple of pages I
> got from searches, I don't get the difference. Basically, I am currently
> using simple session variables (e.g. Session("UserName") =
> txtLastName.Text). I think they are expiring for some users (longer
> sessions?) and I need to be able to set the expiration to something like
> Now() plus 2 hours.
> What is the right way to do this?
> Wayne