Session cookie

Hi everyone just a question about sessions cookies

I want to be able to show a specific div only once, per browser session. Obviously a session cookie is the way to go and ideally I would like to be able to link it to the div and not just its contents. I have had a look at a few example methods but they tend to be timed and ideally I would prefer it to be non timed (so if the users quits the browser the div would be visible again but just the once). Most examples I have seen on the net tend to be written in bespoke javascript and I was hoping there was an easy method to do this using Scripty.

Any help would be very kindly received and appreciated

Pems


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

If you don’t specify a date when creating a cookie, it will only last one session. Prototype and Cookiejar.js make cookies a very neat thing to work with.

http://scripty.walterdavisstudio.com/last-viewed/session.html

To do this in Freeway with Protaculous, first use the External JavaScript Action to link cookiejar.js into your page. (You can download it from my example above at:

http://scripty.walterdavisstudio.com/last-viewed/javascripts/cookiejar.js

Next, apply Protaculous to your page, choose prototype-packed from the library picker, and click on the top Function Body button. Paste in the following JavaScript code:

jar = new CookieJar({
	expires: '',
	path: '/'
});
if(!jar.get('sawit')){
	jar.put('sawit',true);
}else{
	$('message').hide();
}

Now choose your div and make sure that it is named ‘message’ in the Title field of the Inspector.

That’s all there is to it.

Walter

On Mar 19, 2012, at 12:19 PM, pems wrote:

Hi everyone just a question about sessions cookies

I want to be able to show a specific div only once, per browser session. Obviously a session cookie is the way to go and ideally I would like to be able to link it to the div and not just its contents. I have had a look at a few example methods but they tend to be timed and ideally I would prefer it to be non timed (so if the users quits the browser the div would be visible again but just the once). Most examples I have seen on the net tend to be written in bespoke javascript and I was hoping there was an easy method to do this using Scripty.

Any help would be very kindly received and appreciated

Pems


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Thank you Walter
That is exactly what I was looking for.

Kindest regards
Pems :slight_smile:


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Nice Walter but does Chrome not like this method - works with other Browsers but not working for me in Chrome 17

David


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Sorry - Ignore that.

All other Browsers worked locally but Chrome had to be online!

D


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi Walter

Is it possible to use this method with the cookie to affect all items with a specific class rather than ID.

You can only have 1 item with a specific ID but you could have several items with the same class.

D


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Sure. Let’s say you applied a message class to these one-time-show elements, then change

$('message').hide();

to

$$('.message').invoke('hide');

and you’re done.

Walter

On Mar 20, 2012, at 8:12 PM, DeltaDave wrote:

Hi Walter

Is it possible to use this method with the cookie to affect all items with a specific class rather than ID.

You can only have 1 item with a specific ID but you could have several items with the same class.

D


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Thanks Walter - will try this tomorrow.

D


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options