Jump to content

Stay Logged Into A Site When Am Offline...


Netty

Recommended Posts

Not quite clear. Do you want users to your site to be able to return to the site without having to log in again? If so, then just use cookies to save the user login data. When they return to the site, check to see if there is a cookie w/ data and if so log them in with that data.

BTW: that's my same response to your identical question in the Computing.net forum. LOL.
I am not sure if you will find a script that you can just cut and paste in and work how you want. Your best bet is to do some reasearch on cookie with php then look for simalar scripts. If you are going to write your own or modify someone elses you will need to know what is going on.
I'm wondering, did you want to be logged onto your website or someone else's?

As for your own website, it's possible but you would need to provide your site.

As for someone else's website, unless you have access to their php code, then no, you can't be able to do it.
Assuming you have a login script you need to add the following functionality:

Upon a successful login, save the username & password (MD5 hash or something similar I hope) to a cookie.

For any pages where you check login status, if the user is not already logged in, check if they have a cookie set and attempt to log them in using those credentials.
Cookie example - one year expire time, more info on http://no.php.net/manual/fi/function.setcookie.php

[code]

<?php
session_start();

// check for valid user on login
if($login_ok) // simplified example
{
setcookie("cookie_name", "cookie_value", time()+60*60*24*365,"/",".yourdomain.com",0);
}


// or on logout, same parameters but with negative expire period
if($logout) // simplified example
{
setcookie("cookie_name", "cookie_value", time()-60*60*24*365,"/",".yourdomain.com",0);
}

?>

[/code]
By your response on Computing.Net I can see that you are wanting to stay logged in to another site. A cookie isn't going to help you do that. It may be possible to launch a php page to log into another site and keep that login state, but I don't know how.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.