friends anybody can help me making session unexpired likewise here coding-talk?? my session get expire soon.. i want it like it wont get expire even if browser restart and also, if user inactive then wont appear online.. few users let open main page n be on it for long then they should out of site but whenever they refresh.. they do not get error of session expire.. hope you all got my point !!
and please also tell its side-effects (harms)!!
lastly, how can i redirect my users on same page from where he posted data.. like he shout on main page then should return on main page.. i am using should as function defined in core.php .. i am using shoutbox on different pages.. how can i return my users on same page, like if he post shout from buddylist then on buddylist, if main page, then on main page, if forums then on forums!! help me with proper solution..
thank you all in advance my all good coding-talk friends n experts:) help me please!!
icedroplet1987 wrote:
friends anybody can help me making session unexpired likewise here coding-talk?? my session get expire soon.. i want it like it wont get expire even if browser restart and also, if user inactive then wont appear online.. few users let open main page n be on it for long then they should out of site but whenever they refresh.. they do not get error of session expire.. hope you all got my point !!
and please also tell its side-effects (harms)!!
lastly, how can i redirect my users on same page from where he posted data.. like he shout on main page then should return on main page.. i am using should as function defined in core.php .. i am using shoutbox on different pages.. how can i return my users on same page, like if he post shout from buddylist then on buddylist, if main page, then on main page, if forums then on forums!! help me with proper solution..
thank you all in advance my all good coding-talk friends n experts:) help me please!!
using something like this works fine for me. does exactly what i expect it to do.
/** If Username And Password Is Correct Set Sessions */
$_SESSION["valid_user"] = $Name;
$_SESSION["valid_time"] = time();
/////
////
///
basically i stay logged in permanently, until 1 of 2 things happen. i click logout and end/destroy session.
or the browser is disconnected from server for a lengthy ammount of time.
i recently created a function using this method.
/** Login */
function login($Name, $Password)
{
$Password = crypt($Password,'password');
$Password_File = file('core/databases/data/passwords.txt');
$Username_File = file('core/databases/data/usernames.txt');
for ($k=0; $k<count($Username_File); $k++)
{
if (rtrim($Password_File[$k]) == $Password && rtrim($Username_File[$k]) == $Name)
{
/** If Username And Password Is Correct Set Sessions */
$_SESSION["valid_user"] = $Name;
$_SESSION["valid_time"] = time();
}
}
} /** End Login Function */
//
//
//
//
then on page its used on.
/** If Form Was submitted */
if (isset($_POST['submit']))
{ /** Call Security Function */
$Name = Security($_POST['Name']);
$Password = Security($_POST['Password']);
/** Call Login Function */
login($Name, $Password);
}
///
//
//
//
now obviously i know you cant use my exact function. it does however show how example 1 is used.
basically not setting a set time for session to end.
Ghost wrote:
using something like this works fine for me. does exactly what i expect it to do.
/** If Username And Password Is Correct Set Sessions */
$_SESSION["valid_user"] = $Name;
$_SESSION["valid_time"] = time();
/////
////
///
basically i stay logged in permanently, until 1 of 2 things happen. i click logout and end/destroy session.
or the browser is disconnected from server for a lengthy ammount of time.
i recently created a function using this method.
/** Login */
function login($Name, $Password)
{
$Password = crypt($Password,'password');
$Password_File = file('core/databases/data/passwords.txt');
$Username_File = file('core/databases/data/usernames.txt');
for ($k=0; $k<count($Username_File); $k++)
{
if (rtrim($Password_File[$k]) == $Password && rtrim($Username_File[$k]) == $Name)
{
/** If Username And Password Is Correct Set Sessions */
$_SESSION["valid_user"] = $Name;
$_SESSION["valid_time"] = time();
}
}
} /** End Login Function */
//
//
//
//
then on page its used on.
/** If Form Was submitted */
if (isset($_POST['submit']))
{ /** Call Security Function */
$Name = Security($_POST['Name']);
$Password = Security($_POST['Password']);
/** Call Login Function */
login($Name, $Password);
}
///
//
//
//
now obviously i know you cant use my exact function. it does however show how example 1 is used.
basically not setting a set time for session to end.
yeah didnt understand much bro.. but thing you mentioned.. i want my user offline as soon as they close browser n want them again logged in if they open browser.. like here coding-talk .. or another lavalair site also doing so.. thats why so interested to do it..
what bout redirection to similar submit pge from same action.. i want my user to complete the action then get redirected to the page where they were!! i mentioned i am using same action for shout but on many pages... so how i redirect users to same page.. like buddylist ashout then it will be on buddylist back, if main page then main page, if forums, then forum... etc.. help regarding this too!!
Added after 2 minutes:
post proper codes abt session stuff.. i will fix on my site.. so post proper.. i dont know valid_user you getting how? post what u sing n should fix on lavalair @ ghost bro:)
coding-talk dont even destroy session on browser close down for a good 10-15mins after.
ive closed browser a number of times, and still been logged in about 10 mins later after restarting browser
or even shutting pc down.
it just depends on the the servers default destroy time i suppose if you dont set a particular time/interval yourself.
as for the redirect thing.
depending how you got it set up.
if your using the if (isset($_POST['submit'])) method
you could try something like.
/** If Form Was submitted */
if (isset($_POST['submit']))
{
/** do your code business here. */
/** then use meta to redirect to same page. */
echo "<meta http-equiv=\"Refresh\" content=\"0; url=PATH/TO/FILE/IN/USE\" />";
}
//
//
//
//
Ghost wrote:
coding-talk dont even destroy session on browser close down for a good 10-15mins after.
ive closed browser a number of times, and still been logged in about 10 mins later after restarting browser
or even shutting pc down.
it just depends on the the servers default destroy time i suppose if you dont set a particular time/interval yourself.
as for the redirect thing.
depending how you got it set up.
if your using the if (isset($_POST['submit'])) method
you could try something like.
/** If Form Was submitted */
if (isset($_POST['submit']))
{
/** do your code business here. */
/** then use meta to redirect to same page. */
echo "<meta http-equiv=\"Refresh\" content=\"0; url=PATH/TO/FILE/IN/USE\" />";
}
//
//
//
//
just a suggestion.
i know meta can do it but it cant be used to redirect user to the place from where he submitted!! meta will need url.. so url will be like main page.. then if somebody shout from buddylist then also he is getting redirect to main page.. i want users to back on same page from where they submitted..
and please tell me where to apply session stuff.. i want session like here!! pls tell for lavalair bro..:(
without any of us actually seeing the source code in mention your having issues with.
all you'll keep getting is suggestions really. and you never really know. the suggestions could well be put
into your script without you actually realizing it.
i say this alot lately. but to save a lengthy process of try this, try that, blah blah.
please start adding the code/file you want help with in either code tags or attachments.
you may find a quicker solution this way.
icedroplet1987 wrote:
i know meta can do it but it cant be used to redirect user to the place from where he submitted!! meta will need url.. so url will be like main page.. then if somebody shout from buddylist then also he is getting redirect to main page.. i want users to back on same page from where they submitted..
and please tell me where to apply session stuff.. i want session like here!! pls tell for lavalair bro..:(
hmmm you can use header function ... wit that you can send to any page you wish
icedroplet1987 wrote:
i know meta can do it but it cant be used to redirect user to the place from where he submitted!! meta will need url.. so url will be like main page.. then if somebody shout from buddylist then also he is getting redirect to main page.. i want users to back on same page from where they submitted..
and please tell me where to apply session stuff.. i want session like here!! pls tell for lavalair bro..:(
ok i know this is a little late. but i made this to check referer and redirect.
/** just change >> path/to/buddylist.php */
if($_SERVER['HTTP_REFERER'] == 'http://'.$_SERVER['SERVER_NAME'].'/path/to/buddylist.php')
{
/** Your Execution code here that does what you want. */
/** Then Can Use Meta Here Also To Redirect To A Totally Different Page */
/** just change >> back/to/path/of/buddylist.php & content="0 to however many seconds to wait on redirect */
echo '<meta http-equiv="Refresh" content="0; url=back/to/path/of/buddylist.php" />';
}
//
//
//
//
//
//
//
it checks that it was referered from the path set, does your execution code, then redirect to
whether you want it to. tested and working.
y are you all going so much complicated just use simple thinks ... less headache and work fine
get last location and from that with help of header you can do waht you was willing is that not simple
using header to redirect is not the best practise expecially when the php file in question has header already set at top of script.
you will be bombarded with cannot modify headers. header already sent by blah blah at line blah. error.
and the post i made about using meta to redirect is so simple a child could do it.
removed last bit of my comment, due to seeing example in an earlier post
Ghost wrote:
using header to redirect is not the best practise expecially when the php file in question has header already set at top of script.
you will be bombarded with cannot modify headers. header already sent by blah blah at line blah. error.
and the post i made about using meta to redirect is so simple a child could do it.
removed last bit of my comment, due to seeing example in an earlier post
ya you are correct but some old java browsers dont exicute meta tage.... and also if net is slow then it will take too long to get redirected.....
and yes what you said abot header location is correct .... im also facing same problem and using meta tag 😊
but on some hosting the heder function work fine like host geter and ewebguru krishna server .....
i was surprised how it work there and not for me .... 😳
im a noob so if i said any blender plzzz dont laugh at me 😢
love_444 wrote:
but on some hosting the heder function work fine like host geter and ewebguru krishna server .....
i was surprised how it work there and not for me .... 😳
im a noob so if i said any blender plzzz dont laugh at me ;(
most probably down to the server not producing error logs.
ive been on a few servers that dont log errors so doesnt show when error appears like header modifying.
just like it wont show if you turn error report off yourself from inside the script.
now im using a more stricter ruling server that does error logging i learn from my past errors and no longer use
header location "unless" the script im writing has no header code to start with. even if meta redirect is slower.
i would prefer to use it over the chance of if someone uses my script on a strict server like mine and they get alot of error's
it doesnt make me look like a good coder, it makes me look bad in the long run.
as the saying goes, its better to be safe. than sorry.