473,405 Members | 2,261 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Prblem Working with Session

Vkas
78
hi Fellows

i had a logout link !!
when the User click!
i used session.clear() through this i clear all the session objects
and then the page is being reponse .redirected to the default page!!

session becomes clear !
works ok until u Click back!
but if u click back button it goes back !!!
i dont want to happen this

how could it stopped
Feb 27 '09 #1
13 1718
PRR
750 Expert 512MB
You need to check on each page whether user is authenticated or not ...and on logout redirect the user to login page or some other page accessible to all...
Expand|Select|Wrap|Line Numbers
  1. if (User.Identity.IsAuthenticated)
  2.         {
  3.             //go on
  4.         }
  5.         else
  6.         {
  7.             //clear session 
  8.             // Redirect to login page
  9.         }
  10.  
In case you are using generic identity you need to set the current thread principal ..
Feb 27 '09 #2
Vkas
78
hi Deep

I am checking it works ok

Un Authorize user is being checked in each page using a id!


but after the user clicks the logout
this is the code !
Session.Clear()
Response.Redirect("Default.aspx")

if i try to access the page throug address bar the page is responded to the default page ! as the user had been logged out and id is being cleared from the session
but

if i clicked back the user again become log in !!
Feb 27 '09 #3
Vkas
78
where iz every one yar !


i havent tesse any of you so much
Feb 28 '09 #4
hiiiiiiiiiiiii
You can use this script code in <head> tag of your pages

<script>
history.forward();
</script>

this will not save your previous history and your back button doesn't show previous page of yours!
Feb 28 '09 #5
kunal pawar
297 100+
use session.abandant();

which dispose all session values. Please do not use session.clear();
Mar 2 '09 #6
Vkas
78
what is the difference Between Both
Can u tell me ! Kunal
Mar 2 '09 #7
kunal pawar
297 100+
I am expecting question.

Session.Abandon:
1) Cancels the current Session.
2) It destoys session from memory.

Session.Clear
1) clears all values from Session state
2) Session Variables are present with blank or null value.
Mar 2 '09 #8
Vkas
78
ok thank you

after i done session .abundant ()
i redirect my page to my Home page !

but when the user clicks on back button it again goes in page yet i have made a check that if the session value becomes empty then user should be redirected to the Home page ! any idea how can i stop the user to go back when he is log out
Mar 2 '09 #9
kunal pawar
297 100+
From log out page do not redirect to home page
create intermediat page, onload of that page it redirectes to home page

for eg. As user click on log out

session.Abandon();
Response.Redirect("ClearHistory.aspx")

In ClearHistory.aspx

using javascript in body tag

onload="windows.location='Default.aspx';"

So when click on logout it redirect to clearHistory and this page alway redirect to Default.aspx so user can not go back
Mar 2 '09 #10
PRR
750 Expert 512MB
have you enabled anonymous login? or denied anonymous users?
also
Expand|Select|Wrap|Line Numbers
  1. FormsAuthentication.SignOut();
  2.  
  3.  
Mar 2 '09 #11
Vkas
78
y i have done that the method that Kunal said worked in my practice site

but i think this method is not a very gud technique i will now make anew login page then would try to Use yours Method
Mar 2 '09 #12
Frinavale
9,735 Expert Mod 8TB
Just so you know, when you click the "back" button in the Web Browser a cached version of your page is shown.

This means that there is no call made to the web server....it is simply showing the person the content of the page that was cached by the browser.

Look into using <meta> tags to tell the web browser not to cache the content...such as:
Expand|Select|Wrap|Line Numbers
  1. <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE, must-revalidate, max-age=0">
  2. <meta http-equiv="expires" content="0">
  3. <meta http-equiv="Pragma" content="no-cache">
From experience, I've found that meta tags don't always work...but if you research this you will have a much better idea of what needs to be done to prevent the cached page from being displayed when the back button is clicked.
Mar 2 '09 #13
Vkas
78
ok Frinavale!

I will research on the thing that you have told me !

and then will try to impliment them in my Site ! thanks again!

If i couldnt then Will get help from all of the Experience people here!
Mar 3 '09 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Larry Woods | last post by:
I have a site that works fine for days, then suddenly, I start getting ASP 0115 errors with an indication that session variables IN SEPARATE SESSIONS have disappeared! First, for background...
8
by: Brad Simon | last post by:
I have written a shopping cart using ASP .NET (VB). It has been running quite successfully on a site for about a year or so. I use the SessionID as the key to hold information on the shopping...
2
by: Aryan | last post by:
Hi, I have put my session related parameter in web.config under system.web, given below is the code for same. <system.web> <sessionState timeout ="1440" mode ="InProc" /> </system.web> this...
43
by: davidkoree | last post by:
I mean not about cookie. Does it have something to do with operating system or browser plugin? I appreciate any help.
5
by: abhilashcashok | last post by:
hi guys, my prblem is that I cannot update sql query against MS ACCESS using C#. Everytime wen i do so, i got an exception (at runtime) as 'UPDATE syntax not correct'. I don find any error in my...
7
by: quincy451 | last post by:
drop table . CREATE TABLE . ( NULL , (16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , NULL , NULL , (16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , (16) COLLATE
6
by: ChrisAtWokingham | last post by:
I have been struggling with unexpected error messages on an ASP.NET system, using SQL and C#. The application draws organisation charts, based on data stored in the SQL database. Some of the chart...
1
by: =?Utf-8?B?VGltIEhhbHBpbiAoQlYp?= | last post by:
I have 2 disk drives on my pc and bot are dvd-roms and neither are working. 1 says please instert a disk even thought there is one in the drive. The second says application not found when you...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.