Session is not available in different browser
Moderator: General Moderators
-
deecee2000
- Forum Newbie
- Posts: 1
- Joined: Tue Jun 16, 2009 3:36 pm
Session is not available in different browser
My code:
File1.php
<?php
session_start();
$_SESSION['name'] = 'ABC';
?>
File2.php
<?php
session_start();
if(isset($_SESSION['name'])
{
echo "Session Set";
}
else
{
echo "Session not Set";
}
?>
When I try to run first file "file1.php" and then "file2.php" in Firefox, session value showing correctly at file2.php
But then if I try "file2.php" in IE the session value is not showing there.
How can I fix this issue.
Any help would appreciated.
Thanks in Advance.
File1.php
<?php
session_start();
$_SESSION['name'] = 'ABC';
?>
File2.php
<?php
session_start();
if(isset($_SESSION['name'])
{
echo "Session Set";
}
else
{
echo "Session not Set";
}
?>
When I try to run first file "file1.php" and then "file2.php" in Firefox, session value showing correctly at file2.php
But then if I try "file2.php" in IE the session value is not showing there.
How can I fix this issue.
Any help would appreciated.
Thanks in Advance.
Re: Session is not available in different browser
You can't copy session values across browsers like that.
Re: Session is not available in different browser
The session id is stored in a cookie. Browsers use their own cookie management.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Session is not available in different browser
You most certainly can. A quick google for "session hijacking" will prove this wrong.tasairis wrote:You can't copy session values across browsers like that.
However, I think the OP misspoke a little. Perhaps he meant to say after repeating the process that worked in FF, the same did not work in IE.
..but as jackpf hinted, do you have cookies enabled in IE?
Re: Session is not available in different browser
I was careful: note the inclusion of "like that"John Cartwright wrote:You most certainly can. A quick google for "session hijacking" will prove this wrong.tasairis wrote:You can't copy session values across browsers like that.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Session is not available in different browser
Touchétasairis wrote:I was careful: note the inclusion of "like that"John Cartwright wrote:You most certainly can. A quick google for "session hijacking" will prove this wrong.tasairis wrote:You can't copy session values across browsers like that.
Re: Session is not available in different browser
What you could do, is if the user is using the same IP address, give them all the session data for that IP address. Although...this would be a major security risk
But I guess it is possible.
But I guess it is possible.
Re: Session is not available in different browser
The problem is those people who are using the same IP. Like people browsing from behind the same router.jackpf wrote:What you could do, is if the user is using the same IP address, give them all the session data for that IP address. Although...this would be a major security risk![]()
But I guess it is possible.
The next-best would be to store information in the database (whatever "the database" is) and associate it with a user. The user has to log in to get their settings and information, but it's there.
Re: Session is not available in different browser
Yeah...that's what I meant by being a security risk. Unless the previous user explicitly logged out, the next user of the same IP address will have all their login info.
And yeah...but doesn't that defeat the point of transferring the session?
Surely the only reason you'd want to do this is so that a user doesn't have to log in multiple times in different browsers...
And yeah...but doesn't that defeat the point of transferring the session?
Surely the only reason you'd want to do this is so that a user doesn't have to log in multiple times in different browsers...