Jump to content

Register session as infinity


aniesh82

Recommended Posts

 

 

 

Hello Friends,

 

I need to register a session as infinity. How can I do this? Could someone help me ?

 

I also tried with the following code, but did not work.

 

ini_set("session.gc_maxlifetime","864000");

Link to comment
Share on other sites

I tried by editing the php.ini

 

I have set 

ini_set("session.gc_maxlifetime","864000"); 

ini_set('session.cookie_lifetime',"864000"); 

in the php script and added one php.ini file in the directory which it executes. But session get expired after some hours.

 

Thanks in advance.

Link to comment
Share on other sites

 

hello ToonMariner,

 

When we login in PHPFREAKS  can select any the option from select box like one hour, 2 hour, one day etc. Did you note that ?

 

I closed my browser and I returned on the next I saw that  login exists. How it happened?

 

 

Link to comment
Share on other sites

How it happened?

 

Cookies. if the user selects to be logged in forever, create a cookie that says so. Then, next visit, check for the existence of this cookie, if it exists, log the user in using sessions.

Link to comment
Share on other sites

 

Thorpe, Thanks for your reply.

 

So it is not possible to do this using sessions?

 

I am not sure but I think that, session id is stored in browser as a cookie, when we register a new session by server to identify the browser.

 

If this happen, how is not possible to store the session id as a cookie exists forever like you says ?

Link to comment
Share on other sites

If this happen, how is not possible to store the session id as a cookie exists forever like you says ?

 

It may be, but its not practical. That is not the intended pupose of sessions. What is wrong with cookies? That is there intended purpose.

Link to comment
Share on other sites

Let's pretend that you're coding some form of login script.... The suedo-php for this could be as follows:

 

if(session is set) {
show page
}
else {
if(cookie containing username and password is set) {
	if(username and pass are correct) {
			set session
			set cookie (if you want to...)
			exit script
	}
	else {
		unset cookie
		echo wrong pass
	}
}
elseif(POST data containing username and password is set) {
	if(username and pass are correct) {
		set session and cookie
		refresh page
		exit script
	}
	else {
		echo wrong pass
	}
}
}

html form for logging in goes here

 

It could actually be done a little shorter/more efficiently, but in suedo-code, that seemed like the best way.

Link to comment
Share on other sites

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.