session problem with IE8 in php - php

I have a simple code to check counter.
session_start();
if(!isset($_SESSION['footerimg']) || empty($_SESSION['footerimg']) ){
$_SESSION['footerimg']='sunset.jpg';
echo $_SESSION['footerimg'];
}
But all time this is printing "sinsut.jpg" when is page is loading my session is being destroy.
This is running well in FF but problem happeninig with IE and chrome.

This is most definitely because IE8 doesn't accept cookies from localhost. Check this question.

Related

php session not working in chrome and firefox but works in IE

i know this is a well asked question, but the solution provided doesn't clarify my query... :(
php sessions aren't working as expected... for first few tries, the session doesn't get logged.. but after fourth or fifth try, the session is getting logged.. not sure why this doesn't work at first instant...
works with IE but not with fireforx and chrome..
code:
in every page...
<?php
session_start();
?>
in session page...
<?php
session_start();
.
.
.
$_SESSION['name']=$row['name'];
$_SESSION['id']=$row['id'];
session_write_close();
}
thanks in advance... please respond! :)
Try opening the same page in Incognito Window of chrome.PS. You can open Incognito window of chrome by pressing Ctlr+Shift+N..
Thanks for the hint though, Labib!

session not working in chrome and working in firefox

My session is not working in chrome and safari browser and working in firefox. Can anyone explain why this is happening ?
<?php
session_start();
$sessionuser=$_SESSION['user'];
?>
If I print_r($sessionuser) it is not working in chrome or safari browsers bu working in firefox
I'd say that, other than your code has parsing errors, that you would have to use session_start(); before you use $_SESSION[]
It might be that you have forgotten an old session cookie in firefox. I think it is possible to check this with firebug.
Also check da5id's answer, it will fix the parsing error.
Try this
session_start();
$sessionuser=$_SESSION['user'];
echo $sessionuser;
try the following. It works on my chrome in LINUX.
session_start();
$_SESSION['user'] = "hithere";
$sessionuser=$_SESSION['user'];
print_r($sessionuser);
You have to check your browser cookie. Your session not a set If cookie is disabled. You have to go in browser setting and check cookie setting.
Just try
In my case I just reset chrome browser
Go to chrome://settings/ then click advanced then reset
Just clear the cookies in your Google Chrome in the Setting.
Privacy and Security -> Cookies and other site data -> See all cookies and site data
Search by the domain name or IP and delete the existing cookies.

chrome drops sessions

Hi
I have problems with Google Chrome, while developing a PHP website.
I start a session, and store a flag inside it. But when I reload the page, the session value is not recognized.
What can be wrong? Thanks for reply.
session_start();
if (isset($_SESSION['chrome'])) {
echo 'SESSION OK';
}
else {
$_SESSION['chrome'] = 'yes';
}
This is simple code, but it doesn't work...
I had the exact same problem with Chrome not persisting php sessions on a login system. Found the following article: https://secure.kitserve.org.uk/content/php-session-cookie-problems-google-chrome-and-internet-explorer which says:
When testing a local site in Chromium, you must either access it via IP address (e.g. 127.0.0.1) or set the cookie domain parameter to the empty string.
I hope this helps.
I had exact same problem, but on IIS and ASP.Net Mvc. An F5 would make the session recover, but moving to another page caused the problem again. I posted the answer for another SO question. Try it out and see if works.
I think the answer to this is to use session_name before session_set_cookie_params. For example...
session_name('MySession');
session_set_cookie_params( 3600*24, '/', $_SERVER['HTTP_HOST'], is_https() );
session_cache_expire(60*24); // cache expire 60 mins
Check to see if you deactivated cookies in your browser.

Firefox drops the session variable

I just have a simple session start and assigned a session variable on login. However when I switch pages, the session variable does not stick in Firefox. I can still see the session is there but just not the variable. In IE7, IE8, Chrome, and Safari, it works and sticks. What is happening in Firefox and how can I fix it?
Here is a snippet of the code.
session_start();
if ($_POST['login']) :
$_SESSION['loggedin'] = 1;
endif;
Seems to be a client side issue. Probably Firefox does not send the session cookie.

php session doesn't work in safari

I have a simple login page. Everything works fine in Mozilla and IE. When I try to login in Safari, the session is empty, just a white page. If i check the session id, it gives me the id, but shows nothing else.
echo session_id();
If I copy the page URL and then go to another page, and paste the URL, the browser shows the page.If I refresh it, it disappears again.(but it always shows the session id)
Everything works in Mozilla and IE.
update: Thank you all for your help, yes, it was something on the page, I tried a simple page and it worked. Learned my lesson. Thanks again!
sessions in php use a session cookie, so check this:
is your safari browser allowing cookies?, by default the session cookie it's called "phpsessionid"
are you sure that you used a "session_start()"? (and its better if you use a "session_name()" too)
i hope this helps
Just check Safari's cookie policy.
It looks like your browser just do not send a session id cookie back.
If i check the session id, it gives me the id
It is not session id itself what ou have to check.
But rather if session id is the same as before
if it's the same, there is something with your code.
You have to start to debug it.
Start from running a test file with this code:
<?php
session_start();
if (!isset($_SESSION['counter'])) $_SESSION['counter']=0;
echo "Counter ".$_SESSION['counter']++." раз.<br>
reload";
if it works, make it
<?php
session_start();
if (!isset($_SESSION['counter'])) $_SESSION['counter']=0;
echo "Counter ".$_SESSION['counter']++." раз.<br>
reload";
and find a way to watch an HTTP interchange protocol. That's most important thing - to see what cookies going from server and back. I know no tool for safari but there is ought to be one

Categories