Welcome Guest, Not a member yet? Register   Sign In
Question on Cookies and Sessions
#1

[eluser]carllawl[/eluser]
Ok so I'm a little stumped with sessions and cookies

Mainly cookies, I understand how to set them, but how to I go about checking if theyre set.

Eg there is a 'remember me' check box on the login page, if checked should it set both cookie and a session or just a cookie?

Then how would I go about checking if theyre set in the header file...
and or destroying them?

Id normally use something like this:
setcookie("MySite[Section]", "", mktime(12,0,0,1, 1, 1990));

Is there any set feature in codeignitor to do this or should I go about it the same way as usual?

Carl
#2

[eluser]juanvillegas[/eluser]
Yes, there is a Cookie Helper!

http://ellislab.com/codeigniter/user-gui...elper.html

Don't know exactly, but i think session data is lost when browser is closed, so for remember me you should use Cookies. I repeat: not sure about this.
#3

[eluser]domsworkshop[/eluser]
I just use setcookie() for cookies. To test cookies I create I just echo them out with $_COOKIE['value'] (there's probably a better way but I'm practically a novice myself). For session cookies use the session class: http://ellislab.com/codeigniter/user-gui...sions.html

You can use set_userdata() to create a session and either unset_userdata() or sess_destroy() to end a session. The CI documentation is spot-on with describing the various functions. Smile Also have a good look at all the video tutorials available from the Video Tutorials tab, including http://codeigniter.com/wiki/Category:Help::Tutorials, the tutsplus series by Jeffrey Way and Burak Guzel are great and so is the series by Shawn McCool.
#4

[eluser]Byrro[/eluser]
Check the User Guide: http://ellislab.com/codeigniter/user-gui...elper.html

CI is really, really well documented! There´s no need to post it here. Take a look:

Quote:get_cookie()

Lets you fetch a cookie. The first parameter will contain the name of the cookie you are looking for (including any prefixes):

Code:
get_cookie('some_cookie');

The function returns FALSE (boolean) if the item you are attempting to retrieve does not exist.

You don´t have to check if it´s set or not. The function set_cookie() lets you determine the expiration date of the cookie. It´s not deleted when the browser is closed, unless the user set his browser to do so...
#5

[eluser]juanvillegas[/eluser]
[quote author="Byrro" date="1283158349"]Check the User Guide: http://ellislab.com/codeigniter/user-gui...elper.html

CI is really, really well documented! There´s no need to post it here. Take a look:

Quote:get_cookie()

Lets you fetch a cookie. The first parameter will contain the name of the cookie you are looking for (including any prefixes):

Code:
get_cookie('some_cookie');

The function returns FALSE (boolean) if the item you are attempting to retrieve does not exist.

You don´t have to check if it´s set or not. The function set_cookie() lets you determine the expiration date of the cookie. It´s not deleted when the browser is closed, unless the user set his browser to do so...[/quote]

I said SESSION data, not Cookie data
#6

[eluser]Byrro[/eluser]
Then look for SESSION USER GUIDE.... It´s just as simple as the cookie guide.
#7

[eluser]WanWizard[/eluser]
Session data is not lost when you close the browser, session data is lost when the session expires. When that is, depends on your configuration.
If you set the session expiry to 2 years, a remember-me option might not even be needed.




Theme © iAndrew 2016 - Forum software by © MyBB