Solved

Iframes & Sessions

Posted on 2004-08-07
9
3,885 Views
Last Modified: 2012-08-14
Hi,

I've been coding something, and it seems that if I have multiple iframes on one page the pages they display all share the same session.

The only way I can see around this is by using seperate windows instead of iframes, which is not ideal for what I am wanting to do. Is this true that they share the same session, and if this is so, is there a way to make it so they do not?

This has had me stumped all day, and some help would be greatly appreciated :-).

Thanks again!
0
Comment
Question by:Jimmy_A
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 7

Expert Comment

by:suramsureshbabu
ID: 11742406
session is a browser based thing so if you dont close the browser the value will not die.

you can use cookies for storing the values if its possible

try out and if its useful

suresh :)
0
 
LVL 2

Expert Comment

by:kylen1010
ID: 11744270
i had this same problem and it was caused by and error in the code.  check your code again and be sure that all the > and " are in place at the end of all codes.
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 11744823
suresh is right, the session will remain active until the browser is closed (unless there is a time limit of the sessions which is defined in the configuration files).

You can unset session values however i cant understand why you are using sessions if you do not want the session data shared betwen the frames.

0
 

Author Comment

by:Jimmy_A
ID: 11744879
Hi,

Thanks for the input guys.  Just to clarify, the pages I have inside the iframes are totally out of my control.

I'm going to instead use seperate windows, but am encountering the same problem. I'm using javascript to open new windows, and they all seem to be sharing the same session, but when I open the windows manually they do not.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 27

Expert Comment

by:Diablo84
ID: 11744893
its because the session id will be passed via a cookie.

you can delete the contents of a session but the actual session will still be active until the browser window is closed and a new one is opened.

You may wish to use cookies instead but im still not exactly sure why you want to completely terminate the session. As i said you can unset all values that were previously set in a session effectively leaving you with a blank canvas, the same session will still be active but will have no variables assigned to it so you can assign new values.
0
 

Author Comment

by:Jimmy_A
ID: 11745003
Hi,

I'm now a little confused ;-), Basically:

I am opening five new windows with javascript. Each window loads a similar page, and each of these pages has a dynamically generated image on it. On each page in the seperate windows, the dynamically generated image is the same - I am assuming this is because the new windows are sharing a session.

However, when I manually open five browser windows and input the URLs they do not share the same session. I'm not sure why the javascript opened windows are.

If there any way to make it so they do not? I just want a completely different session for these five windows.

Thanks a lot :-)
0
 
LVL 27

Assisted Solution

by:Diablo84
Diablo84 earned 100 total points
ID: 11745018
>> when I manually open five browser windows and input the URLs they do not share the same session. I'm not sure why the javascript opened windows are.

When a new browser window is opened it is classed as a new session whereas when the windows are opened via javascript the cookie information is sent via the http header which sustains the session through to the new page.

>> If there any way to make it so they do not? I just want a completely different session for these five windows.

no, because all the time you are using a single browser window (or following links to a new one) the session is being sustained.

You could however take advantage of the session and set up a variable to display a different image each time, if your working with PHP i can help you out with this, if your working with another language i can advise you but cant code for you.

With regards to your comment, "On each page in the seperate windows, the dynamically generated image is the same" there is a good possibility that this could be a caching issue (although it depends on the role the sessions are playing in the generation of the image). If the browser is loading a cached version of the page then all the images will appear the same.

There are methods of preventing a page caching so that the brwoser has to send a new request for the image/file each time it loads it. A quick google searching for your langauge + prevent caching should give you an answer for that (again, as i dont know what language your working with i cannot tell you this myself).

|)iablo
0
 
LVL 7

Accepted Solution

by:
suramsureshbabu earned 100 total points
ID: 11745097
if you can give us your actual requirements then we might be able to help you. but as said previously by me and diablo if you use javascript to open a new window you cannot kill the session.

one way the session gets killed is when the session times out.

suresh :)
0
 

Author Comment

by:Jimmy_A
ID: 11745447
Thanks guys, I guess we've established that either way is not feasable.

Thanks again for bearing with me, just FYI I'm now going to use a program that opens up new Internet Explorer processes so this problem does not occur.

I've split the points since you've both been very helpful!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction The Google Maps API offers various ways to draw dynamic and static maps.  Using a combination of PHP and JavaScript, you can draw active JavaScript maps that allow pan-and-zoom in the client browser window.  You can also draw "static" …
Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now