Jump to content

Recommended Posts

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.

 

 

 

Thanks for reply,

 

So how can I resolved this problem.

 

Actually I'm working on one stock management apps.

So let say my stock is 100. If user select 10 items then I am subtracting 10 from original one so new user can buy only among 90. not from 100.

 

But in IE it is always shows 100 for new user.

 

That is the issue.

I am in impression that if we store any value in session it will store at server side, not in client computer.

 

So as I told my stock is 100.

If one user come via FF, he buy 10 items,

I am checking that is any value stored in session, it will subtract that value from original qty so if that user will go in other page(current_stock.php) he can able to see 90. That is working fine in FF.

 

Now let say if another user come and open current_stock.php in IE, it is showing 100 instead 90.

 

That is the issue, I want to show always 90(current stock value) in any browser.

 

Thanks,

By default, session ID's are propagated between pages using a cookie. Sessions are also designed to last for one browser session, using the same browser that started the session. Edit: If your application was worried about session security, changing the browser type during a session would be a trigger that indicates a session just got hijacked.

 

To do what you are trying would require that you force php to append the session id on the end of the URL instead of using a cookie (fairly easy to do) and then you would also need to make that URL with the specific session id on it available to each browser (would require that each person accessing the information save a current link to the page and would also require that the next person who comes along to use that link to open the page, therefore, unlikely to happen consistently.)

 

Short answer - if you expect different people to use a browser that is different than the one that started a session to access the same information, you should be storing that information in a database of some kind, not in a session.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.